Skip to content

Commit

Permalink
Add test for stable incidentEdgeOrder support for mutable undirected …
Browse files Browse the repository at this point in the history
…valuegraphs in ValueGraphTest

RELNOTES=n/a

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=288506124
  • Loading branch information
nymanjens authored and netdpb committed Jan 9, 2020
1 parent 9d66951 commit e8e8ba8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void equivalence_considersEdgeValue() {
}

@Test
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder() {
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder_directed() {
graph = ValueGraphBuilder.directed().incidentEdgeOrder(ElementOrder.stable()).build();
graph.putEdgeValue(2, 1, "2-1");
graph.putEdgeValue(2, 3, "2-3");
Expand All @@ -351,6 +351,22 @@ public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder()
.inOrder();
}

@Test
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder_undirected() {
graph = ValueGraphBuilder.undirected().incidentEdgeOrder(ElementOrder.stable()).build();
graph.putEdgeValue(2, 3, "2-3");
graph.putEdgeValue(2, 1, "2-1");
graph.putEdgeValue(2, 4, "2-4");
graph.putEdgeValue(1, 2, "1-2"); // Duplicate nodes, different value

assertThat(graph.incidentEdges(2))
.containsExactly(
EndpointPair.unordered(2, 3),
EndpointPair.unordered(1, 2),
EndpointPair.unordered(2, 4))
.inOrder();
}

@Test
public void concurrentIteration() throws Exception {
graph = ValueGraphBuilder.directed().build();
Expand Down
18 changes: 17 additions & 1 deletion guava-tests/test/com/google/common/graph/ValueGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void equivalence_considersEdgeValue() {
}

@Test
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder() {
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder_directed() {
graph = ValueGraphBuilder.directed().incidentEdgeOrder(ElementOrder.stable()).build();
graph.putEdgeValue(2, 1, "2-1");
graph.putEdgeValue(2, 3, "2-3");
Expand All @@ -411,6 +411,22 @@ public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder()
.inOrder();
}

@Test
public void incidentEdges_stableIncidentEdgeOrder_preservesIncidentEdgesOrder_undirected() {
graph = ValueGraphBuilder.undirected().incidentEdgeOrder(ElementOrder.stable()).build();
graph.putEdgeValue(2, 3, "2-3");
graph.putEdgeValue(2, 1, "2-1");
graph.putEdgeValue(2, 4, "2-4");
graph.putEdgeValue(1, 2, "1-2"); // Duplicate nodes, different value

assertThat(graph.incidentEdges(2))
.containsExactly(
EndpointPair.unordered(2, 3),
EndpointPair.unordered(1, 2),
EndpointPair.unordered(2, 4))
.inOrder();
}

@Test
public void concurrentIteration() throws Exception {
graph = ValueGraphBuilder.directed().build();
Expand Down

0 comments on commit e8e8ba8

Please sign in to comment.