Node
- the type of nodes in the graphpublic final class SCC<Node> extends Object
SCC.Graph
. The components
are computed via of(Graph)
using Tarjan's 1972 algorithm:
Tarjan, R. E. (1972), "Depth-first search and linear graph algorithms", SIAM Journal on Computing, 1 (2): 146–160Components can then be investigated individually, all at once, or simply by using the
representative(Object)
function which maps every node in the graph to a unique node representing
its strongly-connected component.Modifier and Type | Class and Description |
---|---|
static interface |
SCC.Graph<Node>
Interface describing a directed graph whose vertices can
be indexed by integers.
|
Modifier and Type | Method and Description |
---|---|
int |
count() |
void |
iter(Consumer<List<Node>> f)
Iterates the given function
f on all the
strongly-connected components, in reverse topological order
(i.e. a component is always visited before any of its
successors). |
static <Node> SCC<Node> |
of(SCC.Graph<Node> graph)
Computes and returns an instance of
SCC which
describes the strongly connected components of the
given graph . |
Node |
representative(Node n)
The node must belong to the graph for which this
SCC
was computed. |
List<Node> |
scc(Node n)
The node must belong to the graph for which this
SCC
was computed. |
String |
toString() |
public static <Node> SCC<Node> of(SCC.Graph<Node> graph)
SCC
which
describes the strongly connected components of the
given graph
.graph
- graph
count()
,
scc(Object)
,
iter(Consumer)
public int count()
public List<Node> scc(Node n)
SCC
was computed.n
- n
,
where nodes are presented in no particular orderpublic Node representative(Node n)
SCC
was computed.
Representatives are such that two nodes n
and m
are in the same strongly-connected component if and only if
representative(n) == representative(m)
.n
- n
's
strongly-connected componentpublic void iter(Consumer<List<Node>> f)
f
on all the
strongly-connected components, in reverse topological order
(i.e. a component is always visited before any of its
successors).
The relative order of nodes in each component is unspecified.f
-