Skip to content

Instantly share code, notes, and snippets.

@mirsahib
Created March 25, 2019 13:29
Show Gist options
  • Save mirsahib/02fa924570618bac27b96a01655fc758 to your computer and use it in GitHub Desktop.
Save mirsahib/02fa924570618bac27b96a01655fc758 to your computer and use it in GitHub Desktop.
try:
import Queue as Q
except:
import queue as Q
class node:
def __init__(self,nodeId,cost,predecessor,visited):
self.nodeId = nodeId
self.cost = cost
self.predecessor = predecessor
self.visited = False
def __cmp__(self,other):
return cmp(self.cost,other.cost)
def __str__(self):
return str(self.nodeId)+" "+str(self.cost)+" "+str(self.predecessor)+" "+str(self.visited)
a = node(1,10,1,False)
b = node (2,5,1,False)
c = node (3,1,2,False)
q = Q.PriorityQueue()
q.put(a)
q.put(b)
q.put(c)
while not q.empty():
temp = q.get()
print(temp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment