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)
| 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. |