Class VertexPartition<V,E>

java.lang.Object
edu.uci.ics.jung.algorithms.blockmodel.VertexPartition<V,E>

public class VertexPartition<V,E> extends 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.
  • Field Details

    • vertex_partition_map

      private Map<V,Set<V>> vertex_partition_map
    • vertex_sets

      private Collection<Set<V>> vertex_sets
    • graph

      private Graph<V,E> graph
  • Constructor Details

    • VertexPartition

      public VertexPartition(Graph<V,E> g, Map<V,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(Graph<V,E> g, Map<V,Set<V>> partition_map, Collection<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(Graph<V,E> g, Collection<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 Details

    • getGraph

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

      public Map<V,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 Collection<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 String toString()
      Overrides:
      toString in class Object