Add a directed edge. Parameters ---------- u_of_edge : object The start end of this edge v_of_edge : object The destination end of this edge edge_attr : keywords arguments, optional The attribute of the edge. Not
(self, u_of_edge, v_of_edge, **edge_attr)
| 647 | self._node[node].update(node_attr) |
| 648 | |
| 649 | def add_edge(self, u_of_edge, v_of_edge, **edge_attr): |
| 650 | """Add a directed edge. |
| 651 | |
| 652 | Parameters |
| 653 | ---------- |
| 654 | u_of_edge : object |
| 655 | The start end of this edge |
| 656 | |
| 657 | v_of_edge : object |
| 658 | The destination end of this edge |
| 659 | |
| 660 | edge_attr : keywords arguments, optional |
| 661 | The attribute of the edge. |
| 662 | |
| 663 | Notes |
| 664 | ----- |
| 665 | Nodes of this edge will be automatically added to the graph, if they do not exist. |
| 666 | |
| 667 | See Also |
| 668 | -------- |
| 669 | add_edges |
| 670 | |
| 671 | Examples |
| 672 | -------- |
| 673 | |
| 674 | >>> G.add_edge(1,2) |
| 675 | >>> G.add_edge('Jack', 'Tom', weight=10) |
| 676 | |
| 677 | Add edge with attributes, edge weight, for example, |
| 678 | |
| 679 | >>> G.add_edge(1, 2, **{ |
| 680 | ... 'weight': 20 |
| 681 | ... }) |
| 682 | |
| 683 | """ |
| 684 | self._add_one_edge(u_of_edge, v_of_edge, edge_attr) |
| 685 | |
| 686 | def add_weighted_edge(self, u_of_edge, v_of_edge, weight): |
| 687 | self._add_one_edge(u_of_edge, v_of_edge, edge_attr={"weight": weight}) |