def test_no_return_path(self):
graph = nx.MultiDiGraph()
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_b, "cam")
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_b)
assert not result.has_edge(self.switch_port_b, self.switch_port_a)
assert result.out_degree(self.switch_port_a) == 1
assert self.switch_port_b not in result
评论列表
文章目录