educative.io

Formula to find possible edges in directed and undirected graph

for Undirected graph formula should be n*(n-1) and directed it should be n*(n-1)/2. But in article it’s reversed.

Can you explain the logic behind this?

An undirected graph has nC2 edges, which turns out to be n*(n-1)/2. By law, if an undirected graph becomes a directed graph, it will have twice the number of edges.

Undirected:
a – b

Directed:
a -> b
b -> a

Hence, the total number of edges in a directed graph would be:
2 * n*(n-1)/2 = n*(n-1)