1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
package net.sourceforge.combean.test.graph.util; |
23 | |
|
24 | |
import junit.framework.TestCase; |
25 | |
import net.sourceforge.combean.graph.NumberNode; |
26 | |
import net.sourceforge.combean.graph.iterators.IncidentEdgeAsOutgoingEdgeIterator; |
27 | |
import net.sourceforge.combean.interfaces.graph.EdgeIterator; |
28 | |
import net.sourceforge.combean.samples.simplegraphs.Clique; |
29 | |
import net.sourceforge.combean.samples.simplegraphs.NumberGraph; |
30 | |
import net.sourceforge.combean.test.helpers.checks.CheckGraph; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class TestIncidentEdgeAsOutgoingEdgeIterator extends TestCase { |
37 | |
|
38 | |
private static final int GRAPHSIZE = 5; |
39 | 6 | private Clique clique = null; |
40 | 6 | private NumberNode firstNode = null; |
41 | 6 | private NumberNode secondNode = null; |
42 | |
|
43 | 6 | private EdgeIterator itEdgeFirst = null; |
44 | |
|
45 | |
public static void main(String[] args) { |
46 | 0 | junit.textui.TestRunner |
47 | |
.run(TestIncidentEdgeAsOutgoingEdgeIterator.class); |
48 | 0 | } |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
protected void setUp() throws Exception { |
54 | 6 | super.setUp(); |
55 | |
|
56 | 6 | this.clique = new Clique(GRAPHSIZE); |
57 | 6 | this.firstNode = new NumberNode(NumberGraph.FIRSTNODE); |
58 | 6 | this.secondNode = new NumberNode(NumberGraph.FIRSTNODE+1); |
59 | 6 | this.itEdgeFirst = this.clique.getIncidentEdges(this.firstNode); |
60 | 6 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
protected void tearDown() throws Exception { |
66 | 6 | super.tearDown(); |
67 | 6 | } |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public TestIncidentEdgeAsOutgoingEdgeIterator(String name) { |
74 | 6 | super(name); |
75 | 6 | } |
76 | |
|
77 | |
public final void testIterationThroughFilteredNeighborsAtSource() { |
78 | 3 | EdgeIterator itFiltered = |
79 | |
new IncidentEdgeAsOutgoingEdgeIterator(this.clique, |
80 | |
this.firstNode, this.itEdgeFirst); |
81 | 3 | CheckGraph.checkNumIterations(itFiltered, GRAPHSIZE-1); |
82 | 3 | } |
83 | |
|
84 | |
public final void testIterationThroughFilteredNeighborsNotAtSource() { |
85 | 3 | EdgeIterator itFiltered = |
86 | |
new IncidentEdgeAsOutgoingEdgeIterator(this.clique, |
87 | |
this.secondNode, this.itEdgeFirst); |
88 | 3 | CheckGraph.checkNumIterations(itFiltered, 0); |
89 | 3 | } |
90 | |
} |