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

Method neighbors

easygraph/classes/graph.py:631–655  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

graph_to_d_atleast2Function · 0.95
topological_generationsFunction · 0.45
_get_alias_edgeFunction · 0.45
_node2vec_walkFunction · 0.45
_deepwalk_walkFunction · 0.45
k_coreFunction · 0.45
_independent_cascadeFunction · 0.45
_linear_thresholdFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected