Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def walk(node):
queue = [node]
while queue:
node = queue.pop()
yield node
for child in node.children.itervalues():
if child != node:
queue.append(child)
nodes = list(walk(trie.root))
# nodes
for node in nodes:
if node.output != pyahocorasick.nil:
writeln("\tnode%d [shape=doublecircle, label=\"\"]" % id(node))
else:
writeln("\tnode%d [shape=circle, label=\"\"]" % id(node))
# trie edges
for node in nodes:
for letter, child in node.children.iteritems():
nodeid = id(node)
destid = id(child)
if destid == id(trie.root):
# do not show self-links of root node created during make_automaton
continue
if letter.isalnum():
label = letter
else: