Class StronglyConnectedComponentsAlgo

java.lang.Object
org.jhotdraw8.graph.algo.StronglyConnectedComponentsAlgo

public class StronglyConnectedComponentsAlgo extends Object
Computes the sets of strongly connected components in a directed graph.

References:

Stackoverflow. Non-recursive version of Tarjan's algorithm. Copyright Ivan Stoev. CC BY-SA 4.0 license.
stackoverflow.com
Wikipedia. Tarjan's strongly connected components algorithm
wikipedia.org
  • Constructor Details

    • StronglyConnectedComponentsAlgo

      public StronglyConnectedComponentsAlgo()
  • Method Details

    • findStronglyConnectedComponents

      public <V, A> @NonNull List<List<V>> findStronglyConnectedComponents(@NonNull DirectedGraph<V,A> graph)
      Returns all strongly connected components in the specified graph.
      Type Parameters:
      V - the vertex data type
      A - the arrow data type
      Parameters:
      graph - the graph
      Returns:
      set of strongly connected components (sets of vertices).
    • findStronglyConnectedComponents

      public <V> @NonNull List<List<V>> findStronglyConnectedComponents(@NonNull Collection<? extends V> vertices, @NonNull Function<V,Iterable<? extends V>> nextNodeFunction)
      Returns all strongly connected components in the specified graph.
      Type Parameters:
      V - the vertex data type
      Parameters:
      vertices - the vertices of the graph
      nextNodeFunction - returns the next nodes of a given node
      Returns:
      set of strongly connected components (sets of vertices).