|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javautils.collections.Algs | +--javautils.graph.Graphs
Static utility methods for dealing with graphs.
Field Summary |
Fields inherited from class javautils.collections.Algs |
EMPTY_ARRAY, EMPTY_LIST, EMPTY_MAP, EMPTY_SEQUENCE, EMPTY_SET |
Constructor Summary | |
Graphs()
|
Method Summary | |
static ImmutablePair |
asSourceTargetPair(Graph graph,
java.lang.Object edge)
|
static java.lang.String |
asString(Graph graph)
A string representation of the graph, where node ids are the nodes themselves and edge ids are assigned using a counter. |
static java.lang.String |
asString(Graph graph,
Function nodeToIdFun,
Function edgeToIdFun)
A string representation of the graph. |
static AugmentedGraph |
augmented(Graph graph)
Augmented view of the given graph. |
static java.util.Collection |
connectedComponents(Graph directedGraph)
The connected components of the given graph. |
static java.util.Iterator |
edges(Graph graph)
A sequence of all edges of the graph. |
static java.util.Set |
edgeSet(Graph graph)
A set of all edges of the graph. |
static void |
forEachEdge(Graph graph,
Function proc)
Calls the given procedure for each edge of the given graph. |
static void |
forEachNode(Graph graph,
Function proc)
Calls the given procedure for each node of the given graph. |
static Graph |
inducedByEdgesAndContainingNodes(Graph graph,
java.util.Iterator edges,
java.util.Iterator includedNodes)
A graph induced by the specified edges and additionally containing the specified nodes. |
static boolean |
invariant(Graph graph)
True if and only if the invariant of the graph holds. |
static boolean |
isAcyclic(Graph graph)
True iff the given graph is acyclic. |
static boolean |
isIncoming(Graph graph,
java.lang.Object edge,
java.lang.Object node)
True iff the given node is the target of the given edge. |
static boolean |
isSelf(Graph graph,
java.lang.Object edge)
True iff the given edge is a self edge. |
static java.util.List |
nodesByDecreasingDfsFinishingTime(Graph graph)
A list of all nodes of the given graph in order of decreasing DFS-finishing time. |
static java.util.List |
nodesByIncreasingIndegree(Graph graph)
A list of all nodes of the given graph in increasing order of indegree. |
static java.util.List |
nodesByIncreasingOutdegree(Graph graph)
A list of all nodes of the given graph in increasing order of outdegree. |
static java.util.Set |
nodeSet(Graph graph)
A set of all nodes of the graph. |
static java.util.Set |
nodesReachableFrom(Graph graph,
java.util.Collection roots)
|
static java.util.Set |
nodesReachableFrom(Graph graph,
java.util.Iterator roots)
Set of nodes reachable from the specified roots. |
static java.util.Set |
nodesReachableFrom(Graph graph,
java.lang.Object root)
|
static java.lang.Object |
otherNode(Graph graph,
java.lang.Object edge,
java.lang.Object node)
The other node of the edge. |
static Graph |
randomGraph(int numNodes,
int numEdges)
A new random graph with the specified number of nodes and edges. |
static Graph |
restrictedToNodes(Graph graph,
java.util.Collection nodes)
|
static Graph |
restrictedToNodes(Graph graph,
java.util.Iterator nodes)
A graph restricted to the specified nodes and edges between the specified nodes. |
static Graph |
restrictedToNodes(Graph graph,
java.lang.Object[] nodes)
|
static boolean |
sameNodesAndEdges(Graph lhs,
Graph rhs)
True if and only if the given graphs have the same nodes and edges. |
static java.util.Collection |
stronglyConnectedComponents(Graph graph)
The strongly connected components of the given directed graph. |
static Graph |
transitiveIrreflexiveClosure(Graph graph)
Transitive, irreflexive closure of the given graph. |
static AugmentedGraph |
transposed(AugmentedGraph graph)
Transpose view of the given finite graph. |
static Graph |
transposed(Graph graph)
Transpose view of the given finite graph. |
static UndirectedGraph |
undirected(Graph graph)
Undirected view of the given finite graph. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Graphs()
Method Detail |
public static java.lang.String asString(Graph graph)
A string representation of the graph, where node ids are the nodes themselves and edge ids are assigned using a counter.
public static java.lang.String asString(Graph graph, Function nodeToIdFun, Function edgeToIdFun)
A string representation of the graph.
public static AugmentedGraph augmented(Graph graph)
Augmented view of the given graph. If the given graph is already augmented, the same graph will simply be returned.
public static java.util.Collection connectedComponents(Graph directedGraph)
The connected components of the given graph. The graph is
interpreted as undirected. Two nodes a
and
b
are in the same component if there exists a path,
{{a,c0}, {c0,c1}, ..., {cn,b}}
, between them. The result
is a collection of component graphs.
public static java.util.Iterator edges(Graph graph)
A sequence of all edges of the graph.
public static java.util.Set edgeSet(Graph graph)
A set of all edges of the graph.
public static void forEachEdge(Graph graph, Function proc)
Calls the given procedure for each edge of the given graph.
public static void forEachNode(Graph graph, Function proc)
Calls the given procedure for each node of the given graph.
public static Graph inducedByEdgesAndContainingNodes(Graph graph, java.util.Iterator edges, java.util.Iterator includedNodes)
A graph induced by the specified edges and additionally containing the specified nodes.
public static boolean invariant(Graph graph)
True if and only if the invariant of the graph holds. This method handles both graphs and augmented graphs.
public static boolean isAcyclic(Graph graph)
True iff the given graph is acyclic. This method is not meaningful on undirected graphs.
public static boolean isIncoming(Graph graph, java.lang.Object edge, java.lang.Object node)
True iff the given node is the target of the given edge.
public static boolean isSelf(Graph graph, java.lang.Object edge)
True iff the given edge is a self edge.
public static java.util.List nodesByIncreasingIndegree(Graph graph)
A list of all nodes of the given graph in increasing order of indegree.
public static java.util.List nodesByIncreasingOutdegree(Graph graph)
A list of all nodes of the given graph in increasing order of outdegree.
public static java.util.List nodesByDecreasingDfsFinishingTime(Graph graph)
A list of all nodes of the given graph in order of decreasing DFS-finishing time.
public static java.util.Set nodesReachableFrom(Graph graph, java.util.Iterator roots)
Set of nodes reachable from the specified roots.
public static java.util.Set nodesReachableFrom(Graph graph, java.util.Collection roots)
public static java.util.Set nodesReachableFrom(Graph graph, java.lang.Object root)
public static java.util.Set nodeSet(Graph graph)
A set of all nodes of the graph.
public static java.lang.Object otherNode(Graph graph, java.lang.Object edge, java.lang.Object node)
The other node of the edge.
public static Graph randomGraph(int numNodes, int numEdges)
A new random graph with the specified number of nodes and edges.
public static Graph restrictedToNodes(Graph graph, java.util.Iterator nodes)
A graph restricted to the specified nodes and edges between the specified nodes.
public static Graph restrictedToNodes(Graph graph, java.util.Collection nodes)
public static Graph restrictedToNodes(Graph graph, java.lang.Object[] nodes)
public static boolean sameNodesAndEdges(Graph lhs, Graph rhs)
True if and only if the given graphs have the same nodes and edges.
public static ImmutablePair asSourceTargetPair(Graph graph, java.lang.Object edge)
public static java.util.Collection stronglyConnectedComponents(Graph graph)
The strongly connected components of the given directed graph. The result is a collection of collections of nodes of each component.
public static Graph transitiveIrreflexiveClosure(Graph graph)
Transitive, irreflexive closure of the given graph.
public static AugmentedGraph transposed(AugmentedGraph graph)
Transpose view of the given finite graph. The transpose view shares the same node and edge objects with the original graph.
Note: Neither the original graph nor the transpose view should ever be modified.
public static Graph transposed(Graph graph)
Transpose view of the given finite graph. The transpose view shares the same node and edge objects with the original graph.
Note: Neither the original graph nor the transpose view should ever be modified.
public static UndirectedGraph undirected(Graph graph)
Undirected view of the given finite graph. The undirected view shares the same node objects with the original graph.
Note:
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |