Created
March 25, 2019 13:29
-
-
Save mirsahib/02fa924570618bac27b96a01655fc758 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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