def test_reduce_simple_case_lldp(self):
graph = nx.MultiDiGraph(name="simple case lldp")
graph.add_edge(self.switch_a, self.switch_port_a)
graph.add_edge(self.switch_b, self.switch_port_b)
graph.add_edge(self.switch_port_a, self.switch_port_b, "lldp")
graph.add_edge(self.switch_port_b, self.switch_port_a, "lldp")
reducer = AdjacencyReducer(graph)
print("input:")
print(reducer.format_connections())
reducer.reduce()
print("result:")
print(reducer.format_connections())
result = reducer.graph
assert result.has_edge(self.switch_port_a, self.switch_port_b)
assert result.has_edge(self.switch_port_b, self.switch_port_a)
assert result.out_degree(self.switch_port_a) == 1
assert result.out_degree(self.switch_port_b) == 1
评论列表
文章目录