Coverage details for edu.uci.ics.jung.graph.predicates.CliqueGraphPredicate

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 /*
11  * Created on Mar 22, 2004
12  */
13 package edu.uci.ics.jung.graph.predicates;
14  
15 import java.util.Iterator;
16 import java.util.Set;
17  
18 import edu.uci.ics.jung.graph.ArchetypeGraph;
19 import edu.uci.ics.jung.graph.Vertex;
20  
21 /**
22  * Returns true if this graph is a clique (that is, if
23  * each vertex in the graph is a neighbor of each other
24  * vertex; also known as a <i>complete graph</i>).
25  *
26  * @author danyelf
27  */
28 public class CliqueGraphPredicate extends GraphPredicate {
29  
30     private static final String message = "CliqueGraphPredicate";
31     private static CliqueGraphPredicate instance;
32     
33     protected CliqueGraphPredicate()
34     {
351        super();
361    }
37     
38     public static CliqueGraphPredicate getInstance()
39     {
4010        if (instance == null)
411            instance = new CliqueGraphPredicate();
4210        return instance;
43     }
44     
45     /**
46      * @see edu.uci.ics.jung.graph.predicates.GraphPredicate#evaluateGraph(edu.uci.ics.jung.graph.ArchetypeGraph)
47      */
48     public boolean evaluateGraph(ArchetypeGraph g) {
4911        for (Iterator iter = g.getVertices().iterator(); iter.hasNext();) {
5043            Vertex v = (Vertex) iter.next();
5143            int wanted = g.numVertices() - 1;
5243            Set s = v.getNeighbors();
53             
5443            if( s.contains( v ))
5520                wanted += 1;
5643            if (s.size() != wanted)
573                return false;
58         }
598        return true;
60         
61     }
62  
63     public String toString() {
640        return message;
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.