return new VertexPartition<V, E>(g, intermediate, rv);
Graph<V,E> original = partitioning.getGraph(); Graph<CV, CE> collapsed = graph_factory.get(); for (Set<V> set : partitioning.getVertexPartitions()) Map<V, Set<V>> vertex_partitions = partitioning.getVertexToPartitionMap();
Graph<V,E> original = partitioning.getGraph(); Graph<CV, CE> collapsed = graph_factory.create(); for (Set<V> set : partitioning.getVertexPartitions()) Map<V, Set<V>> vertex_partitions = partitioning.getVertexToPartitionMap();
@Override public VertexPartition<V, E> transform(Graph<V, E> g) { Set<Pair<V>> vertex_pairs = getEquivalentPairs(g); Set<Set<V>> rv = new HashSet<Set<V>>(); Map<V, Set<V>> intermediate = new HashMap<V, Set<V>>(); for (Pair<V> p : vertex_pairs) { Set<V> res = intermediate.get(p.getFirst()); if (res == null) { res = intermediate.get(p.getSecond()); } if (res == null) { res = new HashSet<V>(); } res.add(p.getFirst()); res.add(p.getSecond()); intermediate.put(p.getFirst(), res); intermediate.put(p.getSecond(), res); } rv.addAll(intermediate.values()); // pick up the vertices which don't appear in intermediate; they are // singletons (equivalence classes of size 1) Collection<V> singletons = CollectionUtils.subtract(g.getVertices(), intermediate.keySet()); for (V v : singletons) { Set<V> v_set = Collections.singleton(v); intermediate.put(v, v_set); rv.add(v_set); } return new VertexPartition<V, E>(g, intermediate, rv); }
Graph<V, E> original = partitioning.getGraph(); Graph<CV, CE> collapsed = graph_factory.create(); for (Set<V> set : partitioning.getVertexPartitions()) { CV cv = vertex_factory.create(); collapsed.addVertex(vertex_factory.create()); Collection<CV> collapsed_vertices = new HashSet<CV>(); Map<V, Set<V>> vertex_partitions = partitioning .getVertexToPartitionMap();
return new VertexPartition<V, E>(g, intermediate, rv);