def test_circular_layout_hole(self): g = retworkx.generators.path_graph(5) g.remove_nodes_from([1]) res = retworkx.circular_layout(g) expected = { 0: (0.999999986090933, 2.1855693665697608e-08), 2: (-3.576476059301554e-08, 1.0), 3: (-0.9999999701976796, -6.556708099709282e-08), 4: (1.987150711625619e-08, -0.9999999562886126), } self.assertLayoutEquiv(expected, res)
def test_circular_layout_center(self): res = retworkx.circular_layout(self.graph, center=(0.5, 0.5)) expected = { 0: (1.5, 0.5000000266236708), 1: (1.3090170042900713, 1.0877852653564983), 2: (0.8090169789580973, 1.4510565581329224), 3: (0.1909829793186517, 1.4510564985282783), 4: (-0.30901704601332214, 1.0877852057518542), 5: (-0.49999998211860686, 0.4999999392008951), 6: (-0.3090169268040337, -0.08778533131844535), 7: (0.1909829197140075, -0.4510564452809367), 8: (0.8090171279697079, -0.4510564452809367), 9: (1.309016944685427, -0.08778527171380102), } self.assertLayoutEquiv(expected, res)
def test_circular_layout_scale(self): res = retworkx.circular_layout(self.graph, scale=2) expected = { 0: (2.0, 5.324734170386122e-08), 1: (1.6180340085801423, 1.1755705307129969), 2: (0.6180339579161946, 1.9021131162658451), 3: (-0.6180340413626966, 1.9021129970565567), 4: (-1.6180340920266443, 1.1755704115037084), 5: (-1.9999999642372137, -1.2159820987984948e-07), 6: (-1.6180338536080674, -1.1755706626368907), 7: (-0.618034160571985, -1.9021128905618734), 8: (0.6180342559394159, -1.9021128905618734), 9: (1.618033889370854, -1.175570543427602), } self.assertLayoutEquiv(expected, res)
def test_circular_layout(self): res = retworkx.circular_layout(self.graph) expected = { 0: (1.0, 2.662367085193061e-08), 1: (0.8090170042900712, 0.5877852653564984), 2: (0.3090169789580973, 0.9510565581329226), 3: (-0.3090170206813483, 0.9510564985282783), 4: (-0.8090170460133221, 0.5877852057518542), 5: (-0.9999999821186069, -6.079910493992474e-08), 6: (-0.8090169268040337, -0.5877853313184453), 7: (-0.3090170802859925, -0.9510564452809367), 8: (0.3090171279697079, -0.9510564452809367), 9: (0.809016944685427, -0.587785271713801), } self.assertLayoutEquiv(expected, res)
def test_shell_layout_empty(self): res = retworkx.circular_layout(retworkx.PyGraph()) self.assertEqual({}, res)
def test_circular_layout_one_node(self): res = retworkx.circular_layout(retworkx.generators.path_graph(1)) self.assertEqual({0: (0.0, 0.0)}, res)