diff --git a/GG2DP5_hf01.zip b/GG2DP5_hf01.zip
index 5b981f93a2355bc9cb5851aa9de40ca109ba35a1..1b50ddb4af035f113c67658fe6ee379c74d25a70 100644
Binary files a/GG2DP5_hf01.zip and b/GG2DP5_hf01.zip differ
diff --git a/input b/input
index c704a046867e07595444a2a64e05db48eab499b0..a7674cdb5dbc21c936b52830f9fbea9d002c21c6 100644
--- a/input
+++ b/input
@@ -14,4 +14,9 @@ point_coordinates
 route_between_points
 1   0
 1   2
-0   2
\ No newline at end of file
+0   2
+
+input3 rossz 2db, majd jo kimenete:
+380.42  84.85   118.79  67.88   106.07
+380.42  465.28  543.06  272.94  364.87
+316.85  368.61  442.56  237.84  325.31
\ No newline at end of file
diff --git a/mi_GG2DP5_hf1.py b/mi_GG2DP5_hf1.py
index 18a7ae87ea766430da99c3ffdcc91581f5c24701..c68f11b7cce074c46f27fefd468d5ad96b9ddeb0 100644
--- a/mi_GG2DP5_hf1.py
+++ b/mi_GG2DP5_hf1.py
@@ -1,9 +1,8 @@
 #########################################
 #   Keszitette Cseh Viktor - GG2DP5     #
-#   2021.10.08                          #
+#   2021.10.11                          #
 #########################################
 
-#import sys
 import math
 
 ##### Global variables #####
@@ -15,73 +14,63 @@ route_between_points = []
 route = []
 calculated_lengths = []
 
-distance = []
-notseenpoints = []
+verticles = []
 
-##### Global functions #####
-def dijkstra(a, b):
-    if(a == b):     # Ekkor elertuk a keresett pontot
-        calculated_lengths.append(distance[b])
-        return
-    
-    for i in range(0, len(route_between_points), 2):  # iteralni a route_between_points-on,  hogy az == e a meghivottal es kiszamolni a szomszedokhoz tartozo utat, ami esetleg legrovidebb lehet
-        if(route_between_points[i] == a):
-            length = calc_route_length(route_between_points[i], route_between_points[i+1])
+##### Classes #####
 
-            if(length +  distance[a] < distance[route_between_points[i+1]]):     # ha kisebb az eddig tudott utvonalnal a most talalt, akkor cserelje ki arra
-                distance[route_between_points[i+1]] = length + distance[a]
+## Ebben fogjuk majd tarolni a graf pontjaihoz tartozo adatokat
+class vertice:
+    def __init__(self, name, x, y, neighbours):
+        self.name = name
+        self.x = x
+        self.y = y
+        self.neighbours = neighbours
+        self.distance = math.inf
 
-        elif(route_between_points[i+1] == a):
-            length = calc_route_length(route_between_points[i], route_between_points[i+1])
+##### Global functions #####
 
-            if(length +  distance[a] < distance[route_between_points[i]]):
-                distance[route_between_points[i]] = length + distance[a]
+## Neve megteveszto, mert ez nem az egesz dijkstra algoritmus, csak a szomszedokat kiszamolo resze. 
+## Amikor az egesz algoritmus itt volt, akkor a csodalatos hf.mit.bme.hu ellenorzo rendszer panaszkodott,
+## hogy tul nagy a rekurzio melysege, igy fail-elt a leadas.....
+def dijkstra(a, b, notseenpoints):
+    if(a.name == b):
+        calculated_lengths.append(a.distance)
+        return
+    
+    for i in a.neighbours:
+        lenght = calc_route_length(a, verticles[i])
+        if(lenght + a.distance < verticles[i].distance):
+            verticles[i].distance = a.distance + lenght
 
+## Ez lenne a dijkstra masodik resze, ami az elozo vegere ment volna kb
 def route_search():
+    notseenpoints = []
+
+    # minden kiszamolando ut, minden kovetkezo legkisebb eleresi utu pontjara meghivja a szomszedok tavolsaganak a kiszamolasat
     for x in range(0,len(route_to_calc),2):
         for i in range(map_config[1]):
             if(i == route_to_calc[x]):
-                distance.append(0)
+                verticles[i].distance = 0
             else:
-                distance.append(math.inf)
-            notseenpoints.append(i)
+                verticles[i].distance = math.inf
+            notseenpoints.append(verticles[i])
 
         while(len(notseenpoints) != 0):
-            minimum_distance = math.inf
-            corresponding_point = None
-            cntr = 0
-
-            for i in range(len(notseenpoints)):
-                if(distance[notseenpoints[i]] != None):  #Meghivni ra a dijkstra algoritmust rekurzivan, ha mar szamoltuk, de ne jartunk meg benne
-                    if(distance[notseenpoints[i]] < minimum_distance):     # Es legkisebb a tavolsaga eddig
-                        cntr += 1
-                        minimum_distance = distance[notseenpoints[i]]
-                        corresponding_point = notseenpoints[i]
-
-            if(cntr > 0):
-                notseenpoints.remove(corresponding_point)
-                dijkstra(corresponding_point, route_to_calc[x+1])
-
-        distance.clear()
+            notseenpoints = sorted(notseenpoints, key=lambda verticle: verticle.distance)
+                        
+            dijkstra(notseenpoints[0], route_to_calc[x+1], notseenpoints)
         notseenpoints.clear()
 
+
 def calc_route_length(a, b):
     
-    # X koordinata lekerese es szamolasa a pitagorasz tetelhez
-    x1 = int(point_coordinates[a*2])
-
-    x2 = int(point_coordinates[b*2])
-
-    x = abs(x1 - x2)
-
-    # Y koordinata lekerese es szamolasa a pitagorasz tetelhez
-
-
-    y1 = int(point_coordinates[a*2+1])
-
-    y2 = int(point_coordinates[b*2+1])
+    # X tavolsag szamolasa pitagorasz tetelhez
+    
+    x = abs(int(a.x) - int(b.x))
 
-    y = abs(y1 - y2)
+    # Y tavolsag szamolasa pitagorasz tetelhez
+    
+    y = abs(a.y - b.y)
 
 
     # Pitagorasz tetel
@@ -111,6 +100,8 @@ def read_from_input():
 
         point_coordinates.append(int(arr[0], 10))
         point_coordinates.append(int(arr[1], 10))
+        temp = vertice(i, int(arr[0], 10), int(arr[1], 10), neighbours = [])
+        verticles.append(temp)
 
     x = input()
 
@@ -120,6 +111,8 @@ def read_from_input():
 
         route_between_points.append(int(arr[0], 10))
         route_between_points.append(int(arr[1], 10))
+        verticles[int(arr[0], 10)].neighbours.append(int(arr[1], 10))
+        verticles[int(arr[1], 10)].neighbours.append(int(arr[0], 10))
 
 def output_lengths():
     output = ""
@@ -135,12 +128,7 @@ def main():
     read_from_input()
     route_search()
     output_lengths()
-    #print(map_config, file=sys.stderr)
-    #print(route_to_calc, file=sys.stderr)
-    #print(point_coordinates, file=sys.stderr)
-    #print(route_between_points, file=sys.stderr)
-    #print("almafa")
-    #print("***" + map_config[0] + "***", file=sys.stderr)
+
 
 if __name__ == "__main__":
     main()
\ No newline at end of file