Added three state variable visit_state which will be useful for more advanced challenges such as topological sort.

This commit is contained in:
Donne Martin
2015-08-23 08:08:46 -04:00
parent 82b74ca7b4
commit 1f45095f60
2 changed files with 16 additions and 2 deletions

View File

@@ -1,11 +1,18 @@
from collections import OrderedDict
from enum import Enum # Python 2 users: Run pip install enum34
class State(Enum):
unvisited = 1
visited = 2
visiting = 3
class Node:
def __init__(self, id):
self.id = id
self.visited = False
self.visit_state = State.unvisited
self.adjacent = OrderedDict() # key = node, val = weight
def __str__(self):