task2dot
task2dot copied to clipboard
Use hashlib (or other deterministic hash lib) to make the figure reproducible?
I notice that running task2dot twice doesn't produce same figure because of the indeterministic hash function. Changing __hash__ function in Node and Edge to following function makes the figure reproducible (My implementation is poor, it's just a hint). Would you consider making the figure reproducible?
class Node:
def __hash__(self):
return secHash(self.kind + self.label)
class Edge:
def __hash__(self):
return secHash(str(self.node1) + str(self.node2))
Where secHash is defined as
from hashlib import sha256
def secHash(s : str):
return int(sha256(s.encode()).hexdigest(), base=16)