diff --git a/resources/graphs/basic_graph/graph.py b/resources/graphs/basic_graph/graph.py index 4899f4f0ceee949b67b2711a645907de7f6b3057..b5a4cc6d57494b957282a4ed1d5ea683d09fae31 100644 --- a/resources/graphs/basic_graph/graph.py +++ b/resources/graphs/basic_graph/graph.py @@ -304,8 +304,12 @@ class BasicGraphDisplay(): # Set coordinates if not manually set. if not connected_node._manually_set_x_coord: connected_node.x_coord = x_coord + else: + x_coord = connected_node.x_coord if not connected_node._manually_set_y_coord: connected_node.y_coord = y_coord + else: + y_coord = connected_node.y_coord # Record extreme positions. if x_coord > farthest_x[0]: @@ -376,8 +380,12 @@ class BasicGraphDisplay(): # Set coordinates if not manually set. if not connected_node._manually_set_x_coord: connected_node.x_coord = x_coord + else: + x_coord = connected_node.x_coord if not connected_node._manually_set_y_coord: connected_node.y_coord = y_coord + else: + y_coord = connected_node.y_coord # Record extreme positions. if x_coord > farthest_x[0]: @@ -405,8 +413,16 @@ class BasicGraphDisplay(): # Get a random position. index = randint(0, len(possible_positions)) position = possible_positions.pop(index) - self._parent._nodes[node.get_name()].x_coord = position[0] - self._parent._nodes[node.get_name()].y_coord = position[1] + + # Set coordinates if not manually set. + if not node._manually_set_x_coord: + node.x_coord = position[0] + else: + position = (node.x_coord, position[1]) + if not node._manually_set_y_coord: + node.y_coord = position[1] + else: + position = (position[0], node.y_coord) # Record extreme positions. if position[0] > farthest_x[0]: