Ejemplo n.º 1
0
 def test_bipartite_layout_hole(self):
     g = retworkx.generators.path_graph(5)
     g.remove_nodes_from([1])
     res = retworkx.bipartite_layout(g, set())
     expected = {
         0: (0.0, -1.0),
         2: (0.0, -0.3333333333333333),
         3: (0.0, 0.3333333333333333),
         4: (0.0, 1.0),
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 2
0
 def test_bipartite_layout(self):
     res = retworkx.bipartite_layout(self.graph, {0, 1, 2, 3, 4})
     expected = {
         0: (-1.0, -0.75),
         1: (-1.0, -0.375),
         2: (-1.0, 0.0),
         3: (-1.0, 0.375),
         4: (-1.0, 0.75),
         5: (1.0, -0.75),
         6: (1.0, -0.375),
         7: (1.0, 0.0),
         8: (1.0, 0.375),
         9: (1.0, 0.75),
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 3
0
 def test_bipartite_layout_ratio(self):
     res = retworkx.bipartite_layout(self.graph, {2, 4, 8}, aspect_ratio=4)
     expected = {
         8: [-1.0, 0.17857142857142858],
         2: [-1.0, -0.17857142857142858],
         4: [-1.0, 0],
         0: [0.42857142857142855, -0.17857142857142858],
         1: [0.42857142857142855, -0.11904761904761907],
         3: [0.42857142857142855, -0.05952380952380952],
         5: [0.42857142857142855, 0],
         6: [0.42857142857142855, 0.05952380952380952],
         7: [0.42857142857142855, 0.11904761904761903],
         9: [0.42857142857142855, 0.17857142857142858],
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 4
0
 def test_bipartite_layout_scale(self):
     res = retworkx.bipartite_layout(self.graph, {0, 1, 2}, scale=2)
     expected = {
         0: (-2.0, -1.0714285714285714),
         1: (-2.0, 2.3790493384824785e-17),
         2: (-2.0, 1.0714285714285714),
         3: (0.8571428571428571, -1.0714285714285714),
         4: (0.8571428571428571, -0.7142857142857143),
         5: (0.8571428571428571, -0.35714285714285715),
         6: (0.8571428571428571, 2.3790493384824785e-17),
         7: (0.8571428571428571, 0.35714285714285704),
         8: (0.8571428571428571, 0.7142857142857141),
         9: (0.8571428571428571, 1.0714285714285714),
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 5
0
 def test_bipartite_layout_center(self):
     res = retworkx.bipartite_layout(self.graph, {4, 5, 6},
                                     center=(0.5, 0.5))
     expected = {
         4: (-0.5, -0.0357142857142857),
         5: (-0.5, 0.5),
         6: (-0.5, 1.0357142857142856),
         0: (0.9285714285714286, -0.0357142857142857),
         1: (0.9285714285714286, 0.14285714285714285),
         2: (0.9285714285714286, 0.3214285714285714),
         3: (0.9285714285714286, 0.5),
         7: (0.9285714285714286, 0.6785714285714285),
         8: (0.9285714285714286, 0.857142857142857),
         9: (0.9285714285714286, 1.0357142857142856),
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 6
0
 def test_bipartite_layout_horizontal(self):
     res = retworkx.bipartite_layout(self.graph, {0, 1, 2, 3},
                                     horizontal=True)
     expected = {
         0: (1.0, -0.9),
         1: (0.3333333333333333, -0.9),
         2: (-0.333333333333333, -0.9),
         3: (-1.0, -0.9),
         4: (1.0, 0.6),
         5: (0.6, 0.6),
         6: (0.2, 0.6),
         7: (-0.2, 0.6),
         8: (-0.6, 0.6),
         9: (-1.0, 0.6),
     }
     self.assertLayoutEquiv(expected, res)
Ejemplo n.º 7
0
 def test_bipartite_layout_empty(self):
     res = retworkx.bipartite_layout(retworkx.PyGraph(), set())
     self.assertEqual({}, res)