Given an integer N which represents the number of Vertices. The Task is to find the maximum number of edges possible in a Bipartite graph of N vertices.
- A Bipartite graph is one which is having 2 sets of vertices.
- The set are such that the vertices in the same set will never share an edge between them.
Input: N = 10
Both the sets will contain 5 vertices and every vertex of first set
will have an edge to every other vertex of the second set
i.e. total edges = 5 * 5 = 25
Input: N = 9
Approach: The number of edges will be maximum when every vertex of a given set has an edge to every other vertex of the other set i.e. edges = m * n where m and n are the number of edges in both the sets. in order to maximize the number of edges, m must be equal to or as close to n as possible. Hence, the maximum number of edges can be calculated with the formula,
Below is the implementation of the above approach:
- Maximum number of edges to be added to a tree so that it stays a Bipartite graph
- Maximum number of edges among all connected components of an undirected graph
- Ways to Remove Edges from a Complete Graph to make Odd Edges
- Count number of edges in an undirected graph
- Minimum number of edges between two vertices of a graph using DFS
- Number of Simple Graph with N Vertices and M Edges
- Minimum number of edges between two vertices of a Graph
- Program to find total number of edges in a Complete Graph
- Check if a given graph is Bipartite using DFS
- Check whether a given graph is Bipartite or not
- Maximum Bipartite Matching
- All vertex pairs connected with exactly k edges in a graph
- Tree, Back, Edge and Cross Edges in DFS of Graph
- Largest subset of Graph vertices with edges of 2 or more colors
- Shortest path with exactly k edges in a directed and weighted graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.