Class ConnectedComponents

    • Field Summary

      Fields 
      Modifier and Type Field Description
      int[] component
      The component of each node.
      int numberOfComponents
      The number of connected components.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ConnectedComponents​(int numberOfComponents, int[] component)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ConnectedComponents compute​(ImmutableGraph symGraph, int threads, it.unimi.dsi.logging.ProgressLogger pl)
      Computes the connected components of a symmetric graph.
      int[] computeSizes()
      Returns the size array for this set of connected components.
      static ImmutableGraph getLargestComponent​(ImmutableGraph symGraph, int threads, it.unimi.dsi.logging.ProgressLogger pl)
      Returns the largest connected components of a symmetric graph.
      static void main​(java.lang.String[] arg)  
      void sortBySize​(int[] size)
      Renumbers by decreasing size the components of this set.
      • Methods inherited from class java.lang.Object

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

      • numberOfComponents

        public final int numberOfComponents
        The number of connected components.
      • component

        public final int[] component
        The component of each node.
    • Constructor Detail

      • ConnectedComponents

        protected ConnectedComponents​(int numberOfComponents,
                                      int[] component)
    • Method Detail

      • compute

        public static ConnectedComponents compute​(ImmutableGraph symGraph,
                                                  int threads,
                                                  it.unimi.dsi.logging.ProgressLogger pl)
        Computes the connected components of a symmetric graph.
        Parameters:
        symGraph - a symmetric graph.
        threads - the requested number of threads (0 for Runtime.availableProcessors()).
        pl - a progress logger, or null.
        Returns:
        an instance of this class containing the computed components.
      • getLargestComponent

        public static ImmutableGraph getLargestComponent​(ImmutableGraph symGraph,
                                                         int threads,
                                                         it.unimi.dsi.logging.ProgressLogger pl)
        Returns the largest connected components of a symmetric graph.
        Parameters:
        symGraph - a symmetric graph.
        threads - the requested number of threads (0 for Runtime.availableProcessors()).
        pl - a progress logger, or null.
        Returns:
        an ImmutableGraph containing the largest connected component of the input graph.
      • computeSizes

        public int[] computeSizes()
        Returns the size array for this set of connected components.
        Returns:
        the size array for this set of connected components.
      • sortBySize

        public void sortBySize​(int[] size)
        Renumbers by decreasing size the components of this set.

        After a call to this method, both the internal status of this class and the argument array are permuted so that the sizes of connected components are decreasing in the component index.

        Parameters:
        size - the components sizes, as returned by computeSizes().
      • main

        public static void main​(java.lang.String[] arg)
                         throws java.io.IOException,
                                com.martiansoftware.jsap.JSAPException
        Throws:
        java.io.IOException
        com.martiansoftware.jsap.JSAPException