Class VertexPartitionCollapser<V,​E,​CV,​CE>


  • public class VertexPartitionCollapser<V,​E,​CV,​CE>
    extends java.lang.Object
    This class transforms a graph with a known vertex partitioning into a graph whose vertices correspond to the input graph's partitions. Two vertices in the output graph are connected if and only if there exists at least one edge between vertices in the corresponding partitions of the input graph. If the output graph permits parallel edges, there will be an edge connecting two vertices in the new graph for each such edge connecting constituent vertices in the input graph.

    Concept based on Danyel Fisher's GraphCollapser in JUNG 1.x.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.commons.collections4.Factory<CE> edge_factory  
      protected org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Graph<CV,​CE>> graph_factory  
      protected java.util.Map<java.util.Set<V>,​CV> set_collapsedv  
      protected org.apache.commons.collections4.Factory<CV> vertex_factory  
    • Constructor Summary

      Constructors 
      Constructor Description
      VertexPartitionCollapser​(org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Graph<CV,​CE>> graph_factory, org.apache.commons.collections4.Factory<CV> vertex_factory, org.apache.commons.collections4.Factory<CE> edge_factory)
      Creates an instance with the specified graph and element factories.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      edu.uci.ics.jung.graph.Graph<CV,​CE> collapseVertexPartitions​(VertexPartition<V,​E> partitioning)
      Creates a new graph whose vertices correspond to the partitions of the supplied graph.
      org.apache.commons.collections4.Transformer<java.util.Set<V>,​CV> getSetToCollapsedVertexTransformer()
      Returns a transformer from vertex sets in the original graph to collapsed vertices in the transformed graph.
      • Methods inherited from class java.lang.Object

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

      • graph_factory

        protected org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Graph<CV,​CE>> graph_factory
      • vertex_factory

        protected org.apache.commons.collections4.Factory<CV> vertex_factory
      • edge_factory

        protected org.apache.commons.collections4.Factory<CE> edge_factory
      • set_collapsedv

        protected java.util.Map<java.util.Set<V>,​CV> set_collapsedv
    • Constructor Detail

      • VertexPartitionCollapser

        public VertexPartitionCollapser​(org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Graph<CV,​CE>> graph_factory,
                                        org.apache.commons.collections4.Factory<CV> vertex_factory,
                                        org.apache.commons.collections4.Factory<CE> edge_factory)
        Creates an instance with the specified graph and element factories.
        Parameters:
        vertex_factory - used to construct the vertices of the new graph
        edge_factory - used to construct the edges of the new graph
        graph_factory - used to construct the new graph
    • Method Detail

      • collapseVertexPartitions

        public edu.uci.ics.jung.graph.Graph<CV,​CE> collapseVertexPartitions​(VertexPartition<V,​E> partitioning)
        Creates a new graph whose vertices correspond to the partitions of the supplied graph.
        Parameters:
        partitioning -
        Returns:
        a new graph whose vertices correspond to the partitions of the supplied graph
      • getSetToCollapsedVertexTransformer

        public org.apache.commons.collections4.Transformer<java.util.Set<V>,​CV> getSetToCollapsedVertexTransformer()
        Returns a transformer from vertex sets in the original graph to collapsed vertices in the transformed graph.