Returns an iterator of a node's neighbors. Parameters ---------- node : Hashable The target node. Returns ------- neighbors : iterator An iterator of a node's neighbors. Examples -------- >>> G = eg.Gr
(self, node)
| 629 | return bunch |
| 630 | |
| 631 | def neighbors(self, node): |
| 632 | """Returns an iterator of a node's neighbors. |
| 633 | |
| 634 | Parameters |
| 635 | ---------- |
| 636 | node : Hashable |
| 637 | The target node. |
| 638 | |
| 639 | Returns |
| 640 | ------- |
| 641 | neighbors : iterator |
| 642 | An iterator of a node's neighbors. |
| 643 | |
| 644 | Examples |
| 645 | -------- |
| 646 | >>> G = eg.Graph() |
| 647 | >>> G.add_edges([(1,2), (2,3), (2,4)]) |
| 648 | >>> for neighbor in G.neighbors(node=2): |
| 649 | ... print(neighbor) |
| 650 | |
| 651 | """ |
| 652 | try: |
| 653 | return iter(self._adj[node]) |
| 654 | except KeyError: |
| 655 | print("No node {}".format(node)) |
| 656 | |
| 657 | all_neighbors = neighbors |
| 658 |
no outgoing calls
no test coverage detected