antoinerg / elementary-circuits-directed-graph

Finds all elementary circuits of a directed graph using Johnson's algorithm (1975)

Home Page:https://www.npmjs.com/package/elementary-circuits-directed-graph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Finding smallest loops?

AdamMarciniak opened this issue · comments

Is there any way to find the smallest loops? So if I have a loop that consists of two inner loops like your example, is there a way to only print out the two inner loops?

@polishdude20 are you referring to the example below?

//       V4      V2
// +-<---o---<---o---<--+
// |             |      |
// o V0          ^      o V3
// |           V1|      |
// +------>------o--->--+

In this example, nodes 1,2 and 3 are not forming an elementary circuit. There really are only two elementary circuits in this case.

Oh so an elementary circuit is where all of the arrows connect front to end in a loop?

From the original publication:

A circuit is a path in which the first and last vertices are identical. A path is elementary if no vertex appears twice. A circuit is elementary if no vertex but the first and the last appears twice. Two elementary circuits are distinct if one is not a cyclic permutation of the other.