@Test public void testTrimLinks() { MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph = ValueGraphBuilder.directed().allowsSelfLoops(false).build(); OspfNeighborConfigId n1 = new OspfNeighborConfigId( "h1", "v", "p", "i", ConcreteInterfaceAddress.parse("192.0.2.0/31")); OspfNeighborConfigId n2 = new OspfNeighborConfigId( "h2", "v", "p", "i", ConcreteInterfaceAddress.parse("192.0.2.1/31")); OspfNeighborConfigId n3 = new OspfNeighborConfigId( "h3", "v", "p", "i", ConcreteInterfaceAddress.parse("192.0.2.2/31")); graph.addNode(n1); graph.addNode(n2); graph.addNode(n3); Ip ip = Ip.parse("192.0.2.0"); OspfSessionProperties s = new OspfSessionProperties(0, new IpLink(ip, ip)); graph.putEdgeValue(n1, n2, s); graph.putEdgeValue(n2, n1, s); graph.putEdgeValue(n1, n3, s); trimLinks(graph); assertThat( graph.edges(), equalTo(ImmutableSet.of(EndpointPair.ordered(n1, n2), EndpointPair.ordered(n2, n1)))); }
@VisibleForTesting static void trimLinks(MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph) { for (EndpointPair<OspfNeighborConfigId> edge : ImmutableSet.copyOf(graph.edges())) { if (!graph.hasEdgeConnecting(edge.target(), edge.source())) { graph.removeEdge(edge.source(), edge.target()); } } }
OspfTopologyUtils { @VisibleForTesting static void trimLinks(MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph) { for (EndpointPair<OspfNeighborConfigId> edge : ImmutableSet.copyOf(graph.edges())) { if (!graph.hasEdgeConnecting(edge.target(), edge.source())) { graph.removeEdge(edge.source(), edge.target()); } } } }
OspfTopologyUtils { @VisibleForTesting static void trimLinks(MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph) { for (EndpointPair<OspfNeighborConfigId> edge : ImmutableSet.copyOf(graph.edges())) { if (!graph.hasEdgeConnecting(edge.target(), edge.source())) { graph.removeEdge(edge.source(), edge.target()); } } } private  OspfTopologyUtils(); }
OspfTopologyUtils { @VisibleForTesting static void trimLinks(MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph) { for (EndpointPair<OspfNeighborConfigId> edge : ImmutableSet.copyOf(graph.edges())) { if (!graph.hasEdgeConnecting(edge.target(), edge.source())) { graph.removeEdge(edge.source(), edge.target()); } } } private  OspfTopologyUtils(); static OspfTopology computeOspfTopology(
      NetworkConfigurations configurations, Topology l3Topology); static CandidateOspfTopology computeCandidateOspfTopology(
      NetworkConfigurations configurations, Topology l3Topology); static void initNeighborConfigs(NetworkConfigurations configurations); }
OspfTopologyUtils { @VisibleForTesting static void trimLinks(MutableValueGraph<OspfNeighborConfigId, OspfSessionProperties> graph) { for (EndpointPair<OspfNeighborConfigId> edge : ImmutableSet.copyOf(graph.edges())) { if (!graph.hasEdgeConnecting(edge.target(), edge.source())) { graph.removeEdge(edge.source(), edge.target()); } } } private  OspfTopologyUtils(); static OspfTopology computeOspfTopology(
      NetworkConfigurations configurations, Topology l3Topology); static CandidateOspfTopology computeCandidateOspfTopology(
      NetworkConfigurations configurations, Topology l3Topology); static void initNeighborConfigs(NetworkConfigurations configurations);  }