I define a graph class which has a function for taking a node name and adding the name and node to a dictionary.When I run the program, I receive the error at the bottom. Why does it think I am giving it two arguments?
class Graph:
def __init__(self):
self.node_list = {}
self.number = 0
def node(node_name):
if node_name in self.node_list.keys:
return node_list[node_name]
else:
node_list[node_name] = Node()
...
def PrefixTrieConstruction(patterns):
trie = Graph()
trie.node('root')
for pattern in patterns:
currentNode = trie.node('root')
for symbol in pattern:
for daughter in currentNode.daughters:
if daughter.label == symbol:
currentNode = daughter
break
else:
node_name = Trie.name_node()
Trie.node(node_name)
Trie.edge(currentNode, node_name, symbol)
currentNode = node_name
return Trie
Traceback (most recent call last):
File "PythonProject2.3.py", line 168, in <module>
main()
File "PythonProject2.3.py", line 163, in main
TrieMatching(text, PrefixTrieConstruction(patterns))
File "PythonProject2.3.py", line 68, in PrefixTrieConstruction
trie.node('root')
TypeError: node() takes 1 positional argument but 2 were given