Class BackEdges
- Namespace
- Graphity
- Assembly
- Graphity.Core.dll
The back edges of a graph: the edges that a depth-first search finds pointing back to a node on its current path, self-loops included.
public static class BackEdges
- Inheritance
-
BackEdges
- Inherited Members
Remarks
Every cycle contains a back edge, so a graph without back edges is a DAG (directed acyclic graph), and removing the back edges of a graph leaves a DAG. They form a feedback arc set, though not in general a smallest one.
Uses the depth-first search of Of(Graph), without recursion: Of(Graph) finds the edges that EdgeTypes classifies as Back, without classifying the others.
Methods
Of(Graph)
Returns the back edges of graph, in the order in which the search finds
them.
public static Edges Of(Graph graph)
Parameters
graphGraphThe graph to search.
Returns
- Edges
The back edges with their edge indices.
Remarks
Unlike the other results that list edges, they do not come in edge index order. For that
order, use Edges.Of(EdgeTypes.Of(graph), EdgeType.Back): the same edges, at the cost of
classifying every edge first.
Time: O(NodeCount + EdgeCount).
Memory: 12 bytes per back edge for the result; while it runs, up to 18 bytes more per
back edge, 2 bits per node and up to 8 x NodeCount bytes for the stack, which grows with the
deepest path.
Exceptions
- ArgumentException
A depth-first path is longer than 2^30 - 29 nodes.