Program to find total number of edges in a Complete Graph
Given N number of vertices of a Graph. The task is to find the total number of edges possible in a complete graph of N vertices.
Complete Graph: A Complete Graph is a graph in which every pair of vertices is connected by an edge.
Input : N = 3 Output : Edges = 3 Input : N = 5 Output : Edges = 10
The total number of possible edges in a complete graph of N vertices can be given as,
Total number of edges in a complete graph of N vertices = ( n * ( n – 1 ) ) / 2
Example 1: Below is a complete graph with N = 5 vertices.
The total number of edges in the above complete graph = 10 = (5)*(5-1)/2.
Below is the implementation of the above idea:
Attention reader! Don’t stop learning now. Participate in the Scholorship Test for First-Step-to-DSA Course for Class 9 to 12 students.