Package minicp.util

Class GraphUtil

java.lang.Object
minicp.util.GraphUtil

public class GraphUtil extends Object
Algorithms and Graph interface
  • Constructor Details

    • GraphUtil

      public GraphUtil()
  • Method Details

    • transpose

      public static GraphUtil.Graph transpose(GraphUtil.Graph graph)
      Transpose the graph i.e. every edge is reversed.
      Parameters:
      graph - a Graph
      Returns:
      a new graph such that every edge is reversed
    • stronglyConnectedComponents

      public static int[] stronglyConnectedComponents(GraphUtil.Graph graph)
      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

      public static boolean pathExists(GraphUtil.Graph graph, int start, int end)
      Checks if a path exists between start and end
      Parameters:
      graph -
      start - a node id from the graph
      end - a node id from the graph
      Returns:
      true if a directed path from start to end exists, false otherwise