Charging Station: Generating All Eulerian Cycles
Let’s learn how to generate Eulerian cycles in graphs.
We'll cover the following
Iterative construction of every possible bypass graph
The inherent difficulty in generating all Eulerian cycles in a graph is keeping track of potentially many different alternatives at any given node. On the opposite end of the spectrum, a simple directed graph, a connected graph in which each node has indegree and outdegree equal to 1, offers a trivial case, since there is only one Eulerian cycle.
Our idea, then, is to transform a single labeled directed graph Graph containing Eulerian cycles to different simple directed graphs, each containing a single Eulerian cycle. This transformation has the property that it’s easily invertible, i.e., that given the unique Eulerian cycle in one of the simple directed graphs, we can easily reconstruct the original Eulerian cycle in Graph.
Given a node in Graph (of indegree greater than 1) with incoming edge () and outgoing edge (), we’ll construct a “simpler” ()-bypass graph in which we remove the edges () and () from Graph, and add a new node along with the edges () and () (figure below (top)).
The new edges () and () in the bypass graph inherit the labels of the removed edges () and (), respectively. The critical property of this graph is revealed by the following exercise.
Get hands-on with 1200+ tech skills courses.