MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / add_node

Method add_node

easygraph/classes/graph.py:659–691  ·  view source on GitHub ↗

Add one node Add one node, type of which is any hashable Python object, such as int, string, dict, or even Graph itself. You can add with node attributes using Python dict type. Parameters ---------- node_for_adding : any hashable Python object N

(self, node_for_adding, **node_attr)

Source from the content-addressed store, hash-verified

657 all_neighbors = neighbors
658
659 def add_node(self, node_for_adding, **node_attr):
660 """Add one node
661
662 Add one node, type of which is any hashable Python object, such as int, string, dict, or even Graph itself.
663 You can add with node attributes using Python dict type.
664
665 Parameters
666 ----------
667 node_for_adding : any hashable Python object
668 Nodes for adding.
669
670 node_attr : keywords arguments, optional
671 The node attributes.
672 You can customize them with different key-value pairs.
673
674 See Also
675 --------
676 add_nodes
677
678 Examples
679 --------
680 >>> G.add_node('a')
681 >>> G.add_node('hello world')
682 >>> G.add_node('Jack', age=10)
683
684 >>> G.add_node('Jack', **{
685 ... 'age': 10,
686 ... 'gender': 'M'
687 ... })
688
689 """
690 self._add_one_node(node_for_adding, node_attr)
691 self._clear_cache()
692
693 def add_nodes(self, nodes_for_adding: list, nodes_attr: List[Dict] = []):
694 """Add nodes with a list of nodes.

Callers 15

to_networkxFunction · 0.95
from_networkxFunction · 0.95
test_is_isolateFunction · 0.95
_find_separation_nodesFunction · 0.95
_commonUpdateFunction · 0.95
test_boolMethod · 0.95
test_specialsMethod · 0.95
test_simple_listMethod · 0.95
test_dynamic_modeMethod · 0.95

Calls 2

_add_one_nodeMethod · 0.95
_clear_cacheMethod · 0.95

Tested by 15

test_is_isolateFunction · 0.76
test_boolMethod · 0.76
test_specialsMethod · 0.76
test_simple_listMethod · 0.76
test_dynamic_modeMethod · 0.76
test_slice_and_spellMethod · 0.76
test_add_parentMethod · 0.76
test_unicode_nodeMethod · 0.76