Package minicp.util
Class GraphUtil
java.lang.Object
minicp.util.GraphUtil
Algorithms and Graph interface
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanpathExists(GraphUtil.Graph graph, int start, int end) Checks if a path exists between start and endstatic int[]Computes the strongly connected components of the graphstatic GraphUtil.Graphtranspose(GraphUtil.Graph graph) Transpose the graph i.e.
-
Constructor Details
-
GraphUtil
public GraphUtil()
-
-
Method Details
-
transpose
Transpose the graph i.e. every edge is reversed.- Parameters:
graph- a Graph- Returns:
- a new graph such that every edge is reversed
-
stronglyConnectedComponents
Computes the strongly connected components of the graph- Parameters:
graph- the input graph on which to compute the strongly connected components- Returns:
- for each node id, an id of the strongly connected components it belongs to
-
pathExists
Checks if a path exists between start and end- Parameters:
graph-start- a node id from the graphend- a node id from the graph- Returns:
- true if a directed path from start to end exists, false otherwise
-