| Line | Hits | Source |
|---|---|---|
| 1 | /* | |
| 2 | * Copyright (c) 2003, the JUNG Project and the Regents of the University | |
| 3 | * of California | |
| 4 | * All rights reserved. | |
| 5 | * | |
| 6 | * This software is open-source under the BSD license; see either | |
| 7 | * "license.txt" or | |
| 8 | * http://jung.sourceforge.net/license.txt for a description. | |
| 9 | */ | |
| 10 | package edu.uci.ics.jung.algorithms.cluster; | |
| 11 | ||
| 12 | import java.util.HashSet; | |
| 13 | import java.util.Iterator; | |
| 14 | import java.util.Set; | |
| 15 | ||
| 16 | import edu.uci.ics.jung.graph.ArchetypeEdge; | |
| 17 | import edu.uci.ics.jung.graph.Graph; | |
| 18 | import edu.uci.ics.jung.utils.GraphUtils; | |
| 19 | ||
| 20 | /** | |
| 21 | * A ClusterSet where each cluster is a set of edge | |
| 22 | * @author Scott White | |
| 23 | */ | |
| 24 | public class EdgeClusterSet extends ClusterSet { | |
| 25 | ||
| 26 | /** | |
| 27 | * Constructs and initializes the set | |
| 28 | * @param underlyingGraph | |
| 29 | */ | |
| 30 | public EdgeClusterSet(Graph underlyingGraph) { | |
| 31 | 1 | super(underlyingGraph); |
| 32 | 1 | } |
| 33 | ||
| 34 | /** | |
| 35 | * Constructs a new graph from the given cluster | |
| 36 | * @param index the position index of the cluster in the collection | |
| 37 | * @return a new graph representing the cluster | |
| 38 | */ | |
| 39 | public Graph getClusterAsNewSubGraph(int index) { | |
| 40 | 0 | return GraphUtils.edgeSetToGraph(getCluster(index),true); |
| 41 | } | |
| 42 | ||
| 43 | /** | |
| 44 | * Creates a new cluster set where each edge and cluster in the new cluster set correspond 1-to-1 with those in | |
| 45 | * the original graph | |
| 46 | * @param anotherGraph a new graph whose edges are equivalent to those in the original graph | |
| 47 | * @return a new cluster set for the specified graph | |
| 48 | */ | |
| 49 | public ClusterSet createEquivalentClusterSet(Graph anotherGraph) { | |
| 50 | 0 | ClusterSet newClusterSet = new EdgeClusterSet(anotherGraph); |
| 51 | 0 | for (Iterator cIt=iterator();cIt.hasNext();) { |
| 52 | 0 | Set cluster = (Set) cIt.next(); |
| 53 | 0 | Set newCluster = new HashSet(); |
| 54 | 0 | for (Iterator udcIt=cluster.iterator();udcIt.hasNext();) { |
| 55 | 0 | ArchetypeEdge edge = (ArchetypeEdge) udcIt.next(); |
| 56 | 0 | ArchetypeEdge equivalentEdge = edge.getEqualEdge(anotherGraph); |
| 57 | 0 | if (equivalentEdge == null) { |
| 58 | 0 | throw new IllegalArgumentException("Can not create equivalent cluster set because equivalent edges could not be found in the other graph."); |
| 59 | } | |
| 60 | 0 | newCluster.add(equivalentEdge); |
| 61 | } | |
| 62 | 0 | newClusterSet.addCluster(newCluster); |
| 63 | } | |
| 64 | 0 | return newClusterSet; |
| 65 | ||
| 66 | } | |
| 67 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |