From e9398fc1585dabcba6b84b8774017ff997da3098 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Wed, 4 Dec 2019 21:35:49 -0500
Subject: [PATCH] Correct some minor bugs for manually set node coordinates

---
 resources/graphs/basic_graph/graph.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/resources/graphs/basic_graph/graph.py b/resources/graphs/basic_graph/graph.py
index 4899f4f..b5a4cc6 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]:
-- 
GitLab