Search code examples
algorithmdata-structuresgraphdirected-graphcyclic-graph

How do I calculate the density of a cyclic graph?


I'm looking to find the density of a directed cyclic graph.

According to Wikipedia,

For undirected simple graphs, the graph density is defined as:

2 * |E| / (|V| * (|V| − 1))

For directed simple graphs, the graph density is defined as:

|E| / (|V| * (|V| − 1))

But I then go on to read the definition of simple graphs:

"A simple graph, as opposed to a multigraph, is an undirected graph in which both multiple edges and loops are disallowed."

I'm confused because the other article mentioned "directed" and "undirected" simple graphs. Now simple graphs can only be undirected? It also states that simple graphs cannot have loops, so I wasn't sure if I would be able to use either of these formulas on my cyclic graph.

I go on to read about multigraphs, but there is no mention of calculating their density.
Is density not something one would be concerned about for graphs with cycles?

On the first article it states:

"the maximal density is 1 (for complete graphs)"

And it looks like complete graphs are a specialized version of multigraphs, so I assume calculating density should make sense.

What formula do I use?


Solution

  • I understand your confusion, but it's really not complicated. Yuo just picked inconsistent definitions from different sources.

    The notion of simple graphs to me has nothing (or few) to do with directed or undirected graphs (and I did my PhD in the field).

    Undirected means that an edge has no start or end point. It is a 2-set (or multiset) of vertices {a,b} (undistinguishable from an edge {b,a}, possibly containing the same vertex twice {a,a}, which is called a loop.

    Directed means that an edge (also sometimes called arc in this case) has a source vertex and a target vertex. That means that it is a 2-tuple (a,b), and there's a difference between (a,b) and (b,a). Again, (a,a) would be a loop.

    Simple means that 1. there are no loops (even that's sometimes defined differently) 2. no edge occurs twice or more often (this would be a multigraph)

    Let's forget for the moment the claim that simple graphs should be undirected.

    Note that 2. means that if there is an edge {a,b} in an undirected graph, it may not contain an edge {b,a}, because that's the same edge. In a directed simple graph, it is still possible to have (a,b) and (b,a).

    Now, the density is the number of edges divided by the maximum number of edges. In a multigraph, there is no maximum number of edges, and hence, the definition you found, only works for simple graphs.

    Simple undirected graphs have at most |V|(|V|-1)/2 edges, simple directed graphs have at most |V|(|V|-1) edges.

    What's confusing is the definition of a simple graph to be undirected. Forget that. In graph theory, there are still inconsistent notions across different sources. I'd prefer not to include undirectedness to simplicity, because it mixes concepts and leaves you with no clear wording for an directed simple graph.