![]() |
VOOZH | about |
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.
Examples:
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.
Implementation:
15
Complexity Analysis: