MCPcopy Index your code
hub / github.com/clips/pattern / add_node

Method add_node

pattern/graph/__init__.py:348–360  ·  view source on GitHub ↗

Appends a new Node to the graph. An optional base parameter can be used to pass a subclass of Node.

(self, id, *args, **kwargs)

Source from the content-addressed store, hash-verified

346 return self.add_edge(*args, **kwargs)
347
348 def add_node(self, id, *args, **kwargs):
349 """ Appends a new Node to the graph.
350 An optional base parameter can be used to pass a subclass of Node.
351 """
352 n = kwargs.pop("base", Node)
353 n = isinstance(id, Node) and id or self.get(id) or n(id, *args, **kwargs)
354 if n.id not in self:
355 self.nodes.append(n)
356 self[n.id] = n; n.graph = self
357 self.root = kwargs.get("root", False) and n or self.root
358 # Clear adjacency cache.
359 self._adjacency = None
360 return n
361
362 def add_edge(self, id1, id2, *args, **kwargs):
363 """ Appends a new Edge to the graph.

Callers 15

appendMethod · 0.95
add_edgeMethod · 0.95
_add_node_copyMethod · 0.95
test_redirectMethod · 0.95
test_insertMethod · 0.95
graph.jsFile · 0.45
setUpMethod · 0.45
test_textMethod · 0.45
setUpMethod · 0.45
setUpMethod · 0.45
test_graph_nodesMethod · 0.45
test_cacheMethod · 0.45

Calls 3

popMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by 12

test_redirectMethod · 0.76
test_insertMethod · 0.76
setUpMethod · 0.36
test_textMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36
test_graph_nodesMethod · 0.36
test_cacheMethod · 0.36
test_pathsMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36
setUpMethod · 0.36