Problem · Graph
Drawing Edge
Learn this problemProblem statement
You are given n labeled vertices. For every unordered pair of distinct vertices, you may either draw one undirected edge between them or leave them disconnected.
A graph may be disconnected. Two graphs are different when at least one pair of vertices has a different edge choice.
Return the number of distinct simple undirected graphs that can be formed, modulo 10^9 + 7.
Complete drawingEdge with the parameter int n and return the result as an int.
Function
drawingEdge(n: int) → intExamples
Example 1
n = 4return = 64Four vertices determine 4 * 3 / 2 = 6 possible edges. Each edge can be absent or present independently, so the number of graphs is 2^6 = 64.
Example 2
n = 2return = 2There is one possible edge between the two vertices. It can be absent or present, so there are 2 graphs.
Constraints
1 <= n <= 10^9