Beispiel #1
0
 def test_transitivity_fulltriangle_directed(self):
     graph = retworkx.PyDiGraph()
     graph.add_nodes_from(list(range(3)))
     graph.add_edges_from_no_data([(0, 1), (1, 0), (0, 2), (2, 0), (1, 2),
                                   (2, 1)])
     res = retworkx.transitivity(graph)
     self.assertEqual(res, 1.0)
Beispiel #2
0
 def test_transitivity_disconnected(self):
     graph = retworkx.PyGraph()
     graph.add_nodes_from(list(range(3)))
     res = retworkx.transitivity(graph)
     self.assertEqual(res, 0.0)
Beispiel #3
0
 def test_transitivity_empty(self):
     graph = retworkx.PyGraph()
     res = retworkx.transitivity(graph)
     self.assertEqual(res, 0.0)
Beispiel #4
0
 def test_transitivity_star(self):
     graph = retworkx.PyGraph()
     graph.add_nodes_from(list(range(5)))
     graph.add_edges_from_no_data([(0, 1), (0, 2), (0, 3), (0, 4)])
     res = retworkx.transitivity(graph)
     self.assertEqual(res, 0.0)
Beispiel #5
0
 def test_transitivity_directed(self):
     graph = retworkx.PyDiGraph()
     graph.add_nodes_from(list(range(5)))
     graph.add_edges_from_no_data([(0, 1), (0, 2), (0, 3), (1, 2)])
     res = retworkx.transitivity(graph)
     self.assertEqual(res, 3 / 10)