Skip to content

Commit

Permalink
Fix DFS test.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 575241826
  • Loading branch information
Jesse-Good authored and copybara-github committed Oct 20, 2023
1 parent 490e713 commit 9e37edd
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void testBreadthFirst() {
.put(2, list(4, 5))
.put(3, list(6, 7))
.buildOrThrow()))
.containsExactly(1, 2, 3, 4, 5, 6, 7);
.containsExactly(1, 2, 3, 4, 5, 6, 7)
.inOrder();
}

@Test
Expand All @@ -52,7 +53,8 @@ public void testDepthFirst() {
.put(2, list(4, 5))
.put(3, list(6, 7))
.buildOrThrow()))
.containsExactly(1, 2, 4, 5, 3, 6, 7);
.containsExactly(1, 2, 4, 5, 3, 6, 7)
.inOrder();
}

private static <T> ImmutableList<T> list(T... items) {
Expand All @@ -65,7 +67,7 @@ private static <T> ImmutableList<T> bfs(T root, Map<T, Iterable<T>> data) {
}

private static <T> ImmutableList<T> dfs(T root, Map<T, Iterable<T>> data) {
return TreeStreams.breadthFirst(root, k -> data.getOrDefault(k, ImmutableList.of()))
return TreeStreams.depthFirst(root, k -> data.getOrDefault(k, ImmutableList.of()))
.collect(ImmutableList.toImmutableList());
}
}

0 comments on commit 9e37edd

Please sign in to comment.