Class SCCs<G extends Graph<G,​N,​E>,​N extends Node<G,​N,​E>,​E extends Edge<G,​N,​E>>

  • Type Parameters:
    G - the type of the target Graphs
    N - the type of Nodes in the target graphs
    E - the type of Edges in the target graphs

    public class SCCs<G extends Graph<G,​N,​E>,​N extends Node<G,​N,​E>,​E extends Edge<G,​N,​E>>
    extends java.lang.Object
    An algorithms that evaluates the strongly connected components a graph. A strongly connected component is a set of nodes of the graph that is strongly connected, that is, where there exist a path in both directions between any two nodes of the set. This is implemented Tarjan's algorithm, computing maximal non-trivial SCCs (i.e., containing at least one edge and such that no other node could be added without breaking strong connectivity).
    See Also:
    Strongly connected component, Tarjan strongly connected components algorithm
    • Constructor Summary

      Constructors 
      Constructor Description
      SCCs()
      Builds the SCCs.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<java.util.Collection<N>> build​(G graph)
      Builds the strongly connected components for the given graph.
      java.util.Collection<java.util.Collection<N>> buildNonTrivial​(G graph)
      Builds the strongly connected components for the given graph.
      java.util.Collection<java.util.Collection<N>> getSCCs()
      Yields the last computed strongly connected components through build(Graph).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SCCs

        public SCCs()
        Builds the SCCs. To run the algorithm, use build(Graph).
    • Method Detail

      • getSCCs

        public java.util.Collection<java.util.Collection<N>> getSCCs()
        Yields the last computed strongly connected components through build(Graph). Note that, depending on the method used for computing them, the returned value might contain all components, including trivial single-node ones.
        Returns:
        a set containing all the strongly connected components
      • buildNonTrivial

        public java.util.Collection<java.util.Collection<N>> buildNonTrivial​(G graph)
        Builds the strongly connected components for the given graph. The returned value can also be accessed later through getSCCs(). Note that the returned value does not contain trivial single-node components. This also holds for the value returned by getSCCs().
        Parameters:
        graph - the graph whose sccs are to be computed
        Returns:
        the set of non trivial sccs
      • build

        public java.util.Collection<java.util.Collection<N>> build​(G graph)
        Builds the strongly connected components for the given graph. The returned value can also be accessed later through getSCCs(). Note that the returned value contains all components, including trivial single-node ones. This also holds for the value returned by getSCCs().
        Parameters:
        graph - the graph whose sccs are to be computed
        Returns:
        the set of all sccs