Given an integer N which is the number of vertices. The task is to find the number of distinct graphs that can be formed. Since the answer can be very large, print the answer % 1000000007.
Input: N = 3
Input: N = 4
- The maximum number of edges a graph with N vertices can contain is X = N * (N – 1) / 2.
- The total number of graphs containing 0 edge and N vertices will be XC0
- The total number of graphs containing 1 edge and N vertices will be XC1
- And so on from number of edges 1 to X with N vertices
- Hence, the total number of graphs that can be formed with n vertices will be:
XC0 + XC1 + XC2 + … + XCX = 2X.
Below is the implementation of the above approach:
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- Find the number of distinct pairs of vertices which have a distance of exactly k in a tree
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Count numbers formed by given two digit with sum having given digits
- Count of alphabets whose ASCII values can be formed with the digits of N
- Find the count of numbers that can be formed using digits 3, 4 only and having length at max N.
- Count Distinct Rectangles in N*N Chessboard
- Count number of distinct substrings of a given length
- Count of N-digit numbers with all distinct digits
- Count of subsequences having maximum distinct elements
- Count of distinct rectangles inscribed in an equilateral triangle
- Count distinct points visited on the number line
- Count of distinct remainders when N is divided by all the numbers from the range [1, N]
- Program to count number of distinct Squares and Cubes upto N
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.