What is the maximum number of edges in a directed graph with n nodes? Is there any upper bound?
There can be as many as n(n-1)/2
edges in the graph if not multi-edge is allowed.
And this is achievable if we label the vertices 1,2,...,n
and there's an edge from i
to j
iff i>j
.
See here.
In a directed graph having N vertices, each vertex can connect to N-1 other vertices in the graph(Assuming, no self loop). Hence, the total number of edges can be are N(N-1).
Can also be thought of as the number of ways of choosing pairs of nodes n choose 2 = n(n-1)/2. True if only any pair can have only one edge. Multiply by 2 otherwise
If the graph is not a multi graph then it is clearly n * (n - 1), as each node can at most have edges to every other node. If this is a multigraph, then there is no max limit.
The correct answer is n*(n-1)/2. Each edge has been counted twice, hence the division by 2. A complete graph has the maximum number of edges, which is given by n choose 2 = n*(n-1)/2.
Undirected is N^2. Simple - every node has N options of edges (himself included), total of N nodes thus N*N