Class VertexPartition<V,​E>


  • public class VertexPartition<V,​E>
    extends java.lang.Object
    Maintains information about a vertex partition of a graph. This can be built from a map from vertices to vertex sets or from a collection of (disjoint) vertex sets, such as those created by various clustering methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g, java.util.Collection<java.util.Set<V>> vertex_sets)
      Creates an instance based on the specified graph and set of disjoint vertex sets, and generates a vertex-to-partition map based on these sets.
      VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g, java.util.Map<V,​java.util.Set<V>> partition_map)
      Creates an instance based on the specified graph and mapping from vertices to vertex sets, and generates a set of partitions based on this mapping.
      VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g, java.util.Map<V,​java.util.Set<V>> partition_map, java.util.Collection<java.util.Set<V>> vertex_sets)
      Creates an instance based on the specified graph, vertex-set mapping, and set of disjoint vertex sets.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      edu.uci.ics.jung.graph.Graph<V,​E> getGraph()
      Returns the graph on which the partition is defined.
      java.util.Collection<java.util.Set<V>> getVertexPartitions()
      Returns a collection of vertex sets, where each vertex in the input graph is in exactly one set.
      java.util.Map<V,​java.util.Set<V>> getVertexToPartitionMap()
      Returns a map from each vertex in the input graph to its partition.
      int numPartitions()
      Returns the number of partitions.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • VertexPartition

        public VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g,
                               java.util.Map<V,​java.util.Set<V>> partition_map)
        Creates an instance based on the specified graph and mapping from vertices to vertex sets, and generates a set of partitions based on this mapping.
        Parameters:
        g - the graph over which the vertex partition is defined
        partition_map - the mapping from vertices to vertex sets (partitions)
      • VertexPartition

        public VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g,
                               java.util.Map<V,​java.util.Set<V>> partition_map,
                               java.util.Collection<java.util.Set<V>> vertex_sets)
        Creates an instance based on the specified graph, vertex-set mapping, and set of disjoint vertex sets. The vertex-set mapping and vertex partitions must be consistent; that is, the mapping must reflect the division of vertices into partitions, and each vertex must appear in exactly one partition.
        Parameters:
        g - the graph over which the vertex partition is defined
        partition_map - the mapping from vertices to vertex sets (partitions)
        vertex_sets - the set of disjoint vertex sets
      • VertexPartition

        public VertexPartition​(edu.uci.ics.jung.graph.Graph<V,​E> g,
                               java.util.Collection<java.util.Set<V>> vertex_sets)
        Creates an instance based on the specified graph and set of disjoint vertex sets, and generates a vertex-to-partition map based on these sets.
        Parameters:
        g - the graph over which the vertex partition is defined
        vertex_sets - the set of disjoint vertex sets
    • Method Detail

      • getGraph

        public edu.uci.ics.jung.graph.Graph<V,​E> getGraph()
        Returns the graph on which the partition is defined.
        Returns:
        the graph on which the partition is defined
      • getVertexToPartitionMap

        public java.util.Map<V,​java.util.Set<V>> getVertexToPartitionMap()
        Returns a map from each vertex in the input graph to its partition. This map is generated if it does not already exist.
        Returns:
        a map from each vertex in the input graph to a vertex set
      • getVertexPartitions

        public java.util.Collection<java.util.Set<V>> getVertexPartitions()
        Returns a collection of vertex sets, where each vertex in the input graph is in exactly one set. This collection is generated based on the vertex-to-partition map if it does not already exist.
        Returns:
        a collection of vertex sets such that each vertex in the instance's graph is in exactly one set
      • numPartitions

        public int numPartitions()
        Returns the number of partitions.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object