txlyre 3 years ago
parent
commit
4e29d2eed4
1 changed files with 3 additions and 0 deletions
  1. 3 0
      yafn/__main__.py

+ 3 - 0
yafn/__main__.py

@@ -150,6 +150,9 @@ def distance(graph, start, end):
   visited = []
   queue = [[start]]
 
+  if start == end:
+    return 0
+
   while queue:
     path = queue.pop(0)
     node = path[-1]