Coverage details for edu.uci.ics.jung.algorithms.cluster.EdgeClusterSet

LineHitsSource
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) {
311        super(underlyingGraph);
321    }
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) {
400        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) {
500        ClusterSet newClusterSet = new EdgeClusterSet(anotherGraph);
510        for (Iterator cIt=iterator();cIt.hasNext();) {
520            Set cluster = (Set) cIt.next();
530            Set newCluster = new HashSet();
540            for (Iterator udcIt=cluster.iterator();udcIt.hasNext();) {
550                ArchetypeEdge edge = (ArchetypeEdge) udcIt.next();
560                ArchetypeEdge equivalentEdge = edge.getEqualEdge(anotherGraph);
570                if (equivalentEdge == null) {
580                    throw new IllegalArgumentException("Can not create equivalent cluster set because equivalent edges could not be found in the other graph.");
59                 }
600                newCluster.add(equivalentEdge);
61             }
620            newClusterSet.addCluster(newCluster);
63         }
640        return newClusterSet;
65  
66     }
67 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.