MCPcopy
hub / github.com/donnemartin/interactive-coding-challenges / add_node

Method add_node

graphs_trees/graph/graph.py:48–53  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

46 self.nodes = {} # Key = key, val = Node
47
48 def add_node(self, key):
49 if key is None:
50 raise TypeError('key cannot be None')
51 if key not in self.nodes:
52 self.nodes[key] = Node(key)
53 return self.nodes[key]
54
55 def add_edge(self, source_key, dest_key, weight=0):
56 if source_key is None or dest_key is None:

Callers 6

add_edgeMethod · 0.95
create_graphMethod · 0.95
test_path_existsMethod · 0.80
test_bfsMethod · 0.80
test_shortest_pathMethod · 0.80
test_dfsMethod · 0.80

Calls 1

NodeClass · 0.70

Tested by 5

create_graphMethod · 0.76
test_path_existsMethod · 0.64
test_bfsMethod · 0.64
test_shortest_pathMethod · 0.64
test_dfsMethod · 0.64