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:
- Ways to Remove Edges from a Complete Graph to make Odd Edges
- Program to find the diameter, cycles and edges of a Wheel Graph
- Minimum number of edges between two vertices of a graph using DFS
- Count number of edges in an undirected graph
- Minimum number of edges between two vertices of a Graph
- Number of Simple Graph with N Vertices and M Edges
- Maximum number of edges among all connected components of an undirected graph
- Maximum number of edges to be added to a tree so that it stays a Bipartite graph
- Total number of Spanning Trees in a Graph
- Total number of Spanning trees in a Cycle Graph
- All vertex pairs connected with exactly k edges in a graph
- Shortest path with exactly k edges in a directed and weighted graph
- Tree, Back, Edge and Cross Edges in DFS of Graph
- Largest subset of Graph vertices with edges of 2 or more colors
- Assign directions to edges so that the directed graph remains acyclic
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.