Skip to content

Commit a53d57c

Browse files
authored
Fix flaky test in testConnectedComponents (#1215)
1 parent c8909a9 commit a53d57c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/src/edu/stanford/nlp/graph/DirectedMultiGraphTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ public void testShortestPathDirectionInsensitiveEdges() {
153153
public void testConnectedComponents() {
154154

155155
System.out.println("graph is " + graph.toString());
156-
List<Set<Integer>> ccs = graph.getConnectedComponents();
156+
Set<Set<Integer>> ccs = new HashSet<>(graph.getConnectedComponents());
157157
for (Set<Integer> cc : ccs) {
158158
System.out.println("Connected component: " + cc);
159-
}
160-
assertEquals(ccs.size(), 4);
161-
assertEquals(CollectionUtils.sorted(ccs.get(0)),
162-
Arrays.asList(1, 2, 3, 4));
159+
}
160+
Set<Integer> edge1 = new HashSet<>(Arrays.asList(1, 2, 3, 4));
161+
Set<Integer> edge2 = new HashSet<>(Arrays.asList(5, 6, 7));
162+
Set<Integer> edge3 = new HashSet<>(Arrays.asList(8));
163+
Set<Integer> edge4 = new HashSet<>(Arrays.asList(9,10));
164+
Set<Set<Integer>> expectedCcs = new HashSet<>(Arrays.asList(edge1,edge2,edge3,edge4));
165+
assertEquals(expectedCcs, ccs);
163166
}
164167

165168
public void testEdgesNodes() {

0 commit comments

Comments
 (0)