@Test public void removeNode_nodeNotPresent() { addNode(N1); ImmutableSet<Integer> nodes = ImmutableSet.copyOf(network.nodes()); assertFalse(network.removeNode(NODE_NOT_IN_GRAPH)); assertThat(network.nodes()).containsExactlyElementsIn(nodes); }
@Test public void removeNode_existingNode() { addEdge(E12, N1, N2); addEdge(E41, N4, N1); assertTrue(network.removeNode(N1)); assertThat(network.nodes()).containsExactly(N2, N4); assertThat(network.edges()).doesNotContain(E12); assertThat(network.edges()).doesNotContain(E41); }
@Test public void removeNode_queryAfterRemoval() { addNode(N1); Set<Integer> unused = network.adjacentNodes(N1); // ensure cache (if any) is populated assertTrue(network.removeNode(N1)); try { network.adjacentNodes(N1); fail(ERROR_NODE_NOT_IN_GRAPH); } catch (IllegalArgumentException e) { assertNodeNotInGraphErrorMessage(e); } }