-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode.py
More file actions
25 lines (20 loc) · 865 Bytes
/
Copy pathnode.py
File metadata and controls
25 lines (20 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# node class
from graph import getEdge
import math
class Node:
def __init__(self, key, graph):
self.id = key
self.color = "empty"
self.neighbors = graph[key]
self.parent = self.id
self.circuitNeighbors = { "black": self.neighbors[:], "white": self.neighbors[:] }
N = int((1/6) * (math.sqrt(24 * len(graph) + 9) + 3)) # Find N value, base size
self.edges = getEdge(self.id, N)
def updateCircuitNeighbors(self, nd):
oppositeColor = "white" if nd.color == "black" else "black"
self.circuitNeighbors[nd.color].remove(nd.id)
for i in nd.circuitNeighbors[nd.color]:
if i == self.id: continue
if i not in self.circuitNeighbors[nd.color]:
self.circuitNeighbors[nd.color].append(i)
self.circuitNeighbors[oppositeColor].remove(nd.id)