|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| UndirectedGraphNode.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
package baseCode.dataStructure.graph;
|
|
| 2 |
|
|
| 3 |
import java.util.HashSet;
|
|
| 4 |
import java.util.Set;
|
|
| 5 |
|
|
| 6 |
/**
|
|
| 7 |
* <p>
|
|
| 8 |
* Copyright (c) Columbia University
|
|
| 9 |
*
|
|
| 10 |
* @author Paul Pavlidis
|
|
| 11 |
* @version $Id: UndirectedGraphNode.java,v 1.4 2004/07/27 03:18:58 pavlidis Exp $
|
|
| 12 |
*/
|
|
| 13 |
public class UndirectedGraphNode extends AbstractGraphNode { |
|
| 14 |
|
|
| 15 |
private Set neighbors;
|
|
| 16 |
|
|
| 17 | 0 |
public UndirectedGraphNode( Object key, Object value, AbstractGraph graph ) {
|
| 18 | 0 |
super( key, value, graph );
|
| 19 | 0 |
neighbors = new HashSet();
|
| 20 |
} |
|
| 21 |
|
|
| 22 | 0 |
public UndirectedGraphNode( Object key ) {
|
| 23 | 0 |
super( key );
|
| 24 | 0 |
neighbors = new HashSet();
|
| 25 |
} |
|
| 26 |
|
|
| 27 | 0 |
public int numNeighbors() { |
| 28 | 0 |
return neighbors.size();
|
| 29 |
} |
|
| 30 |
|
|
| 31 | 0 |
public int compareTo( Object o ) { |
| 32 | 0 |
if ( ( ( UndirectedGraphNode ) o ).numNeighbors() > this.numNeighbors() ) { |
| 33 | 0 |
return -1;
|
| 34 | 0 |
} else if ( ( ( UndirectedGraphNode ) o ).numNeighbors() < this |
| 35 |
.numNeighbors() ) {
|
|
| 36 | 0 |
return 1;
|
| 37 |
} |
|
| 38 | 0 |
return 0;
|
| 39 |
} |
|
| 40 |
|
|
| 41 |
} |
|
||||||||||