Пример #1
0
 def test_shell_layout_hole_two_shells(self):
     g = retworkx.generators.path_graph(5)
     g.remove_nodes_from([2])
     res = retworkx.shell_layout(g, [[0, 1], [3, 4]])
     expected = {
         0: (-2.1855694143368964e-08, 0.5),
         1: (5.962440319251527e-09, -0.5),
         3: (-1.0, -8.742277657347586e-08),
         4: (1.0, 1.7484555314695172e-07),
     }
     self.assertLayoutEquiv(expected, res)
Пример #2
0
 def test_shell_layout_hole(self):
     g = retworkx.generators.path_graph(5)
     g.remove_nodes_from([1])
     res = retworkx.shell_layout(g)
     expected = {
         0: (-1.0, -8.742277657347586e-08),
         2: (1.1924880638503055e-08, -1.0),
         3: (1.0, 1.7484555314695172e-07),
         4: (-3.3776623808989825e-07, 1.0),
     }
     self.assertLayoutEquiv(expected, res)
Пример #3
0
 def test_shell_layout(self):
     res = retworkx.shell_layout(self.graph)
     expected = {
         0: (-1.0, -8.742277657347586e-08),
         1: (-0.8090169429779053, -0.5877853631973267),
         2: (-0.3090170919895172, -0.9510564804077148),
         3: (0.3090171217918396, -0.9510564804077148),
         4: (0.8090172410011292, -0.5877849459648132),
         5: (1.0, 1.7484555314695172e-07),
         6: (0.80901700258255, 0.5877852439880371),
         7: (0.30901679396629333, 0.9510565996170044),
         8: (-0.30901744961738586, 0.9510563611984253),
         9: (-0.8090168833732605, 0.5877854228019714),
     }
     self.assertLayoutEquiv(expected, res)
Пример #4
0
 def test_shell_layout_scale(self):
     res = retworkx.shell_layout(self.graph,
                                 nlist=[[0, 1, 2, 3, 4], [9, 8, 7, 6, 5]],
                                 scale=2)
     expected = {
         0: (-4.371138828673793e-08, 1.0),
         1: (-0.9510565996170044, 0.30901679396629333),
         2: (-0.5877850651741028, -0.8090171217918396),
         3: (0.5877854824066162, -0.8090168237686157),
         4: (0.9510564208030701, 0.30901727080345154),
         9: (-2.0, -1.7484555314695172e-07),
         8: (-0.6180341839790344, -1.9021129608154297),
         7: (1.6180344820022583, -1.1755698919296265),
         6: (1.6180340051651, 1.1755704879760742),
         5: (-0.6180348992347717, 1.9021127223968506),
     }
     self.assertLayoutEquiv(expected, res)
Пример #5
0
 def test_shell_layout_nlist(self):
     res = retworkx.shell_layout(self.graph,
                                 nlist=[[0, 2], [1, 3], [4, 9], [8, 7],
                                        [6, 5]])
     expected = {
         0: (0.16180340945720673, 0.11755704879760742),
         2: (-0.16180339455604553, -0.11755707114934921),
         1: (0.12360679358243942, 0.3804226219654083),
         3: (-0.123606838285923, -0.38042259216308594),
         4: (-0.18541023135185242, 0.5706338882446289),
         9: (0.185410276055336, -0.5706338882446289),
         8: (-0.6472136378288269, 0.4702281653881073),
         7: (0.6472138166427612, -0.4702279567718506),
         6: (-1.0, -8.742277657347586e-08),
         5: (1.0, 1.7484555314695172e-07),
     }
     self.assertLayoutEquiv(expected, res)
Пример #6
0
 def test_shell_layout_rotate(self):
     res = retworkx.shell_layout(self.graph,
                                 nlist=[[0, 1, 2], [3, 4, 5], [6, 7, 8],
                                        [9]],
                                 rotate=0.5)
     expected = {
         0: (0.21939563751220703, 0.11985638737678528),
         1: (-0.21349650621414185, 0.13007399439811707),
         2: (-0.005899117328226566, -0.24993039667606354),
         3: (0.27015113830566406, 0.4207354784011841),
         4: (-0.4994432032108307, 0.023589985445141792),
         5: (0.229292094707489, -0.4443254768848419),
         6: (0.05305289849638939, 0.7481212615966797),
         7: (-0.6744184494018555, -0.3281154930591583),
         8: (0.6213656067848206, -0.420005738735199),
         9: (-0.416146844625473, 0.9092974066734314),
     }
     self.assertLayoutEquiv(expected, res)
Пример #7
0
 def test_shell_layout_center(self):
     res = retworkx.shell_layout(
         self.graph,
         nlist=[[0, 1, 2, 3, 4], [9, 8, 7, 6, 5]],
         center=(0.5, 0.5),
     )
     expected = {
         0: (0.49999997814430586, 1.0),
         1: (0.024471700191497803, 0.6545083969831467),
         2: (0.2061074674129486, 0.0954914391040802),
         3: (0.7938927412033081, 0.09549158811569214),
         4: (0.975528210401535, 0.6545086354017258),
         9: (-0.5, 0.4999999125772234),
         8: (0.1909829080104828, -0.45105648040771484),
         7: (1.3090172410011292, -0.08778494596481323),
         6: (1.30901700258255, 1.087785243988037),
         5: (0.19098255038261414, 1.4510563611984253),
     }
     self.assertLayoutEquiv(expected, res)
Пример #8
0
 def test_shell_layout_one_node(self):
     res = retworkx.shell_layout(retworkx.generators.path_graph(1))
     self.assertEqual({0: (0.0, 0.0)}, res)