|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.algo.GraphConnectivity
public class GraphConnectivity
Provides algorithms for determining certain connectivity components within a graph. Also provides convenience method for working with these components.
Constructor Summary | |
---|---|
GraphConnectivity()
|
Method Summary | |
---|---|
static EdgeList[] |
biconnectedComponents(Graph graph)
Calculates the biconnected components of a given undirected graph. |
static int |
biconnectedComponents(Graph graph,
EdgeMap compNum)
Calculates the biconnected components of a given undirected graph. |
static int |
biconnectedComponents(Graph graph,
EdgeMap compNum,
NodeMap aPoint)
Calculates the biconnected components of a given undirected graph. |
static NodeList[] |
connectedComponents(Graph graph)
Returns the connected components of a given graph. |
static int |
connectedComponents(Graph graph,
NodeMap compNum)
Returns the connected components of a given graph. |
static NodeList |
getNeighbors(Graph graph,
NodeList startNodes,
int maxDistance)
Determines the direct or indirect neighbors of a given set of nodes. |
static NodeList |
getPredecessors(Graph graph,
NodeList startNodes,
int maxDistance)
Determines the direct or indirect predecessors of a given set of nodes. |
static NodeList |
getSuccessors(Graph graph,
NodeList startNodes,
int maxDistance)
Determines the direct or indirect successors of a given set of nodes. |
static boolean |
isBiconnected(Graph graph)
Checks whether or not the given graph his biconnected. |
static boolean |
isConnected(Graph graph)
Checks whether or not the given graph is connected. |
static boolean |
isStronglyConnected(Graph graph)
Checks whether or not the given graph is strongly connected. |
static EdgeList |
makeBiconnected(Graph graph)
Makes the given graph biconnected by inserting a minimum number of edges in the graph. |
static EdgeList |
makeConnected(Graph graph)
Makes a graph connected by adding additional edges to the graph. |
static void |
reachable(Graph graph,
Node start,
boolean directed,
boolean[] reached)
Determines the set of nodes that can be reached in the given graph when starting from a given node. |
static void |
reachable(Graph graph,
Node start,
boolean directed,
boolean[] forbidden,
boolean[] reached)
Similar to reachable(Graph,Node,boolean,boolean[]) . |
static NodeList[] |
stronglyConnectedComponents(Graph graph)
Returns the connected components of a given graph. |
static int |
stronglyConnectedComponents(Graph graph,
NodeMap compNum)
Returns the connected components of a given graph. |
static EdgeList[] |
toEdgeListArray(Graph graph,
EdgeMap compNum,
int maxCompNum)
Transforms the return values of biconnectedComponents(Graph, EdgeMap) to
an array of EdgeList s, like it is returned by
biconnectedComponents(Graph) . |
static NodeList[] |
toNodeListArray(Graph graph,
NodeMap compNum,
int maxCompNum)
Transforms the return values of connectedComponents(Graph, NodeMap) to
an array of type NodeList, like it is returned by
connectedComponents(Graph) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphConnectivity()
Method Detail |
---|
public static NodeList[] connectedComponents(Graph graph)
G
is called connected if there is an
undirected path between each pair of nodes belonging to G
.
The connected components of G
are connected
subgraphs that G
consists of.
graph
- the input graph
public static int connectedComponents(Graph graph, NodeMap compNum)
G
is called connected if there is an
undirected path between each pair of nodes belonging to G
.
The connected components of G
are connected
subgraphs that G
consists of.
graph
- the input graphcompNum
- return value that will hold the zero-based number
of the connected component that it belongs to. The component number of
Node v
is compNum.getInt()
.
public static EdgeList makeConnected(Graph graph)
graph
- the input graph
public static NodeList[] toNodeListArray(Graph graph, NodeMap compNum, int maxCompNum)
connectedComponents(Graph, NodeMap)
to
an array of type NodeList, like it is returned by
connectedComponents(Graph)
.
public static boolean isConnected(Graph graph)
public static EdgeList[] biconnectedComponents(Graph graph)
Note: Selfloops do not belong to any biconnected component. Therefore no selfloops are included in the returned edge lists.
graph
- the input graphpublic static int biconnectedComponents(Graph graph, EdgeMap compNum)
Note: Selfloops do not belong to any biconnected component.
Therefore the component index for selfloops is always -1
.
graph
- the input graphcompNum
- return value that provides for each edge a zero-based index
of the biconnected component it belongs to or
-1
for selfloops.
public static int biconnectedComponents(Graph graph, EdgeMap compNum, NodeMap aPoint)
Note: Selfloops do not belong to any biconnected component.
Therefore the component index for selfloops is always -1
.
aPoint
- return value that provides for each node a boolean value
indicating whether or not it is an articulation point.public static EdgeList[] toEdgeListArray(Graph graph, EdgeMap compNum, int maxCompNum)
biconnectedComponents(Graph, EdgeMap)
to
an array of EdgeList
s, like it is returned by
biconnectedComponents(Graph)
.
public static EdgeList makeBiconnected(Graph graph)
graph
- the input graph
public static boolean isBiconnected(Graph graph)
public static void reachable(Graph graph, Node start, boolean directed, boolean[] reached)
graph
- the graph the search is performed onstart
- the node the search is started fromdirected
- traverses edges only from source to target if true
. Otherwise
traverses edges in both directions.reached
- the return value. a boolean array that has value true
at field
v.index()
iff node v can be reached by the dfs search.public static void reachable(Graph graph, Node start, boolean directed, boolean[] forbidden, boolean[] reached)
reachable(Graph,Node,boolean,boolean[])
. Additionally
it is possible to specify a set of forbidden edges that will not be traversed
when performing the search.
graph
- the graph DFS is performed onstart
- the node DFS is started fromdirected
- traverses edges only from source to target if true
. Otherwise
traverses edges in both directions.forbidden
- marks edges that may not be traversed by DFS. An edge e
is marked as forbidden if forbidden[e.index()] == true
.reached
- the return value. a boolean array that has value true
at field
v.index()
iff node v can be reached by the dfs search.public static NodeList getSuccessors(Graph graph, NodeList startNodes, int maxDistance)
graph
- the graph to act uponstartNodes
- contains the node the search is started frommaxDistance
- limits the distance between a start node and a returned node. For all returned
nodes there must be a path to a start node that has a length equal or smaller than maxDistance.
Setting maxDistance to 1
will only yield the direct successors of all start nodes. On the other hand,
setting maxDistance to graph.N()
or larger, will yield all successors of all start nodes.
public static NodeList getPredecessors(Graph graph, NodeList startNodes, int maxDistance)
graph
- the graph to act uponstartNodes
- contains the node the search is started frommaxDistance
- limits the distance between a start node and a returned node. For all returned
nodes there must be a path to a start node that has a length equal or smaller than maxDistance.
Setting maxDistance to 1
will only yield the direct predecessors of all start nodes. On the other hand,
setting maxDistance to graph.N()
or larger, will yield all predecessors of all start nodes.
public static NodeList getNeighbors(Graph graph, NodeList startNodes, int maxDistance)
graph
- the graph to act uponstartNodes
- contains the node the search is started frommaxDistance
- limits the distance between a start node and a returned node. For all returned
nodes there must be a path to a start node that has a length equal or smaller than maxDistance.
Setting maxDistance to 1
will only yield the direct neighbors of all start nodes. On the other hand,
setting maxDistance to graph.N()
or larger, will yield all neighbors of all start nodes.
public static NodeList[] stronglyConnectedComponents(Graph graph)
G
is called strongly connected if there is an
directed path between each pair of nodes belonging to G
.
The strongly connected components of G
are strongly connected
subgraphs that G
consists of.
graph
- the input graph
public static int stronglyConnectedComponents(Graph graph, NodeMap compNum)
G
is called strongly connected if there is an
directed path between each pair of nodes belonging to G
.
The strongly connected components of G
are strongly connected
subgraphs that G
consists of.
graph
- the input graphcompNum
- return value that will hold the zero-based number
of the strongly connected component that it belongs to. The component number of
Node v
is compNum.getInt()
.
public static boolean isStronglyConnected(Graph graph)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |