test_moral.py 452 B

123456789101112131415
  1. import networkx as nx
  2. from networkx.algorithms.moral import moral_graph
  3. def test_get_moral_graph():
  4. graph = nx.DiGraph()
  5. graph.add_nodes_from([1, 2, 3, 4, 5, 6, 7])
  6. graph.add_edges_from([(1, 2), (3, 2), (4, 1), (4, 5), (6, 5), (7, 5)])
  7. H = moral_graph(graph)
  8. assert not H.is_directed()
  9. assert H.has_edge(1, 3)
  10. assert H.has_edge(4, 6)
  11. assert H.has_edge(6, 7)
  12. assert H.has_edge(4, 7)
  13. assert not H.has_edge(1, 5)