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

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 |  | `/*`
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 |  | `{`
35 | 1 | `super();`
36 | 1 | `}`
37 |  | ``
38 |  | `public static CliqueGraphPredicate getInstance()`
39 |  | `{`
40 | 10 | `if (instance == null)`
41 | 1 | `instance = new CliqueGraphPredicate();`
42 | 10 | `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) {`
49 | 11 | `for (Iterator iter = g.getVertices().iterator(); iter.hasNext();) {`
50 | 43 | `Vertex v = (Vertex) iter.next();`
51 | 43 | `int wanted = g.numVertices() - 1;`
52 | 43 | `Set s = v.getNeighbors();`
53 |  | ``
54 | 43 | `if( s.contains( v ))`
55 | 20 | `wanted += 1;`
56 | 43 | `if (s.size() != wanted)`
57 | 3 | `return false;`
58 |  | `}`
59 | 8 | `return true;`
60 |  | ``
61 |  | `}`
62 |  | ``
63 |  | `public String toString() {`
64 | 0 | `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.