Skip to content

Commit

Permalink
added graph function
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeyo committed Mar 29, 2018
1 parent 6043aec commit d046af5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions d_star_lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def computeShortestPath(graph, queue, s_start, k_m):
updateVertex(graph, queue, u, s_start, k_m)
for i in graph.graph[u].parents:
updateVertex(graph, queue, i, s_start, k_m)
# graph.printGValues()


def nextInShortestPath(graph, s_current):
Expand Down
2 changes: 1 addition & 1 deletion graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __str__(self):
def __repr__(self):
return self.__str__()

def udpate_parents(self, parents):
def update_parents(self, parents):
self.parents = parents


Expand Down
12 changes: 12 additions & 0 deletions grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ def printGrid(self):
for row in self.cells:
print(row)

def printGValues(self):
for j in range(self.y_dim):
str_msg = ""
for i in range(self.x_dim):
node_id = 'x' + str(i) + 'y' + str(j)
node = self.graph[node_id]
if node.g == float('inf'):
str_msg += ' - '
else:
str_msg += ' ' + str(node.g) + ' '
print(str_msg)

def generateGraphFromGrid(self):
edge = 1
for i in range(len(self.cells)):
Expand Down

0 comments on commit d046af5

Please sign in to comment.