Skip to content

Commit eab98c7

Browse files
committed
return child:parent dict for UCS and A*
1 parent 0e13109 commit eab98c7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pgraph/PGraph.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,15 @@ def path_UCS(self, S, G, verbose=False, summary=False):
11131113
path.insert(0, p)
11141114
x = p
11151115

1116+
parent_names = {}
1117+
for v, p in parent.items():
1118+
parent_names[v.name] = p.name
1119+
11161120
if summary or verbose:
11171121
print(
11181122
f"{len(explored)} vertices explored, {len(frontier)} remaining on the frontier")
11191123

1120-
return path, length, parent
1124+
return path, length, parent_names
11211125

11221126
def path_Astar(self, S, G, verbose=False, summary=False):
11231127
"""
@@ -1210,11 +1214,15 @@ def path_Astar(self, S, G, verbose=False, summary=False):
12101214
path.insert(0, p)
12111215
x = p
12121216

1217+
parent_names = {}
1218+
for v, p in parent.items():
1219+
parent_names[v.name] = p.name
1220+
12131221
if summary or verbose:
12141222
print(
12151223
f"{len(explored)} vertices explored, {len(frontier)} remaining on the frontier")
12161224

1217-
return path, length, parent
1225+
return path, length, parent_names
12181226

12191227

12201228
# -------------------------------------------------------------------------- #

0 commit comments

Comments
 (0)