public final class NodeOrders extends Object
(u,v)
, node u
lies before v
in the ordering.
depth first search
.
(v_1,v_2,....,v_n)
of a biconnected graph is a node ordering which guarantees that:Modifier and Type | Method and Description |
---|---|
static NodeList |
dfsCompletion(Graph graph)
Calculates an ordering of the nodes identical to the order of node completion events in a depth first search.
|
static void |
dfsCompletion(Graph graph,
int[] order)
Calculates an ordering of the nodes identical to the order of node completion events in a depth first search.
|
static NodeList |
st(Graph graph)
Assigns an
st -ordering to the nodes of a biconnected graph. |
static void |
st(Graph graph,
int[] stOrder)
Assigns an
st -ordering to the nodes of a biconnected graph given the edge between source node s and sink
node t . |
static void |
st(Graph graph,
int[] stOrder,
Edge stEdge)
Assigns an
st -ordering to the nodes of a biconnected graph given the edge between source node s and sink
node t . |
static NodeList |
toNodeList(Graph graph,
int[] order)
Converts an array-based result returned by a method of this class to a
NodeList that contains all nodes in the
order provided by the given array. |
static void |
toNodeMap(Graph graph,
int[] order,
INodeMap result)
Copies an array-based result returned by a method of this class to a
INodeMap that will provide values of basic
type int . |
static void |
toNodeMap(NodeList order,
INodeMap result)
|
static NodeList |
topological(Graph graph)
Returns a topological ordering of the nodes of a directed acyclic graph.
|
static boolean |
topological(Graph graph,
int[] order)
Assigns a topological ordering to the nodes of a directed acyclic graph.
|
public static final NodeList dfsCompletion(Graph graph)
Like dfsCompletion(Graph, int[])
but the result is returned as a NodeList
.
This ordering is a reversed topological ordering in case the input graph is acyclic.
O(graph.N() + graph.E())
graph
- the input graphNodeList
containing the nodes of the graph in the order identical to the order of node completion events in a
depth first searchtopological(Graph, int[])
,
dfsCompletion(Graph, int[])
public static final void dfsCompletion(Graph graph, int[] order)
This ordering is a reversed topological ordering in case the input graph is acyclic.
O(graph.N() + graph.E())
graph
- the input graphorder
- an array of Integer
s that returns for each Node
v
, its zero-based index within the calculated
ordering, i.e., order[v.index()] == 5
means that v
is the 6
-th node within the orderingtopological(Graph, int[])
,
dfsCompletion(Graph)
public static final NodeList st(Graph graph)
st
-ordering to the nodes of a biconnected graph.
Like st(Graph, int[], Edge)
but the result is returned as a NodeList
.
An st
-ordering (v_1,v_2,....,v_n)
of a biconnected graph is a node ordering which guarantees
that:
s
and sink node t
are connected by an edge.v_i
in the ordering other than s
or t
, there are neighbors v_j
and v_k
with j < i
and k > i
.
biconnected
.O(graph.N() + graph.E())
graph
- the input graphNodeList
containing the nodes of the graph in the order defined by the st
-orderingst(Graph, int[], Edge)
public static final void st(Graph graph, int[] stOrder)
st
-ordering to the nodes of a biconnected graph given the edge between source node s
and sink
node t
.
An st
-ordering (v_1,v_2,....,v_n)
of a biconnected graph is a node ordering which guarantees
that:
s
and sink node t
are connected by an edge.v_i
in the ordering other than s
or t
, there are neighbors v_j
and v_k
with j < i
and k > i
.
stOrder.length == graph.N()
biconnected
.O(graph.N() + graph.E())
graph
- the input graphstOrder
- an array of Integer
s that will be filled during the execution and returns for each Node
v
, its
zero-based index within the calculated ordering, i.e., stOrder[v.index()] == 5
means that v
is the
6
-th node within the orderingst(Graph)
,
st(Graph, int[], Edge)
public static final void st(Graph graph, int[] stOrder, Edge stEdge)
st
-ordering to the nodes of a biconnected graph given the edge between source node s
and sink
node t
.
An st
-ordering (v_1,v_2,....,v_n)
of a biconnected graph is a node ordering which guarantees
that:
s
and sink node t
are connected by an edge.v_i
in the ordering other than s
or t
, there are neighbors v_j
and v_k
with j < i
and k > i
.
stOrder.length == graph.N()
biconnected
.O(graph.N() + graph.E())
graph
- the input graphstOrder
- an array of Integer
s that will be filled during the execution and returns for each Node
v
, its
zero-based index within the calculated ordering, i.e., stOrder[v.index()] == 5
means that v
is the
6
-th node within the orderingstEdge
- an Edge
that connects source node s
and sink node t
st(Graph)
,
st(Graph, int[], Edge)
public static final NodeList toNodeList(Graph graph, int[] order)
NodeList
that contains all nodes in the
order provided by the given array.graph
- the input graphorder
- an array of Integer
s that will be filled during the execution and returns for each Node
v
, its
zero-based index within the calculated ordering, i.e., order[v.index()] == 5
means that v
is the
6
-th node within the orderingNodeList
containing the nodes of the graph in the order provided by the given arraypublic static final void toNodeMap(Graph graph, int[] order, INodeMap result)
INodeMap
that will provide values of basic
type int
.graph
- the input graphorder
- an array of Integer
s that returns for each Node
v
, its zero-based index within the calculated
ordering, i.e., order[v.index()] == 5
means that v
is the 6
-th node within the orderingresult
- the INodeMap
that will be filled during the execution with the zero-based index of each node within the
calculated orderingpublic static final NodeList topological(Graph graph)
IllegalArgumentException
- if the graph is cyclicacyclic
.O(graph.N() + graph.E())
graph
- the input graphNodeList
containing the nodes of the graph in the order they appear in the topological orderingtopological(Graph, int[])
public static final boolean topological(Graph graph, int[] order)
A topological ordering of the nodes of a directed graph is a linear ordering of the nodes such that for each directed
edge (u,v)
, node u
lies before v
in the ordering.
false
leaving the contents of the result array order
unspecified.order.length == graph.N()
O(graph.N() + graph.E())
graph
- the input graphorder
- an array of Integer
s that will be filled during the execution and returns for each Node
v
, its
zero-based index within the calculated ordering, i.e., order[v.index()] == 5
means that v
is the
6
-th node within the orderingtrue
if the graph is acyclic, false
otherwisetopological(Graph)