MCPcopy Create free account
hub / github.com/alibaba/GraphScope / nbunch_iter

Method nbunch_iter

python/graphscope/nx/classes/graph.py:1569–1595  ·  view source on GitHub ↗
(self, nbunch=None)

Source from the content-addressed store, hash-verified

1567 @clear_mutation_cache
1568 @patch_docstring(RefGraph.nbunch_iter)
1569 def nbunch_iter(self, nbunch=None):
1570 if nbunch is None: # include all nodes via iterator
1571 bunch = iter(self.nodes)
1572 elif nbunch in self: # if nbunch is a single node
1573 bunch = iter([nbunch])
1574 else: # if nbunch is a sequence of nodes
1575
1576 def bunch_iter(nlist, adj):
1577 try:
1578 for n in nlist:
1579 if n in adj:
1580 yield n
1581 except TypeError as e:
1582 message = e.args[0]
1583 # capture error for non-sequence/iterator nbunch.
1584 if "iter" in message:
1585 msg = "nbunch is not a node or a sequence of nodes."
1586 raise NetworkXError(msg) from e
1587 # capture error for invalid node.
1588 elif "hashable" in message:
1589 msg = "Node {} in sequence nbunch is not a valid node."
1590 raise NetworkXError(msg) from e
1591 else:
1592 raise
1593
1594 bunch = bunch_iter(nbunch, self._adj)
1595 return bunch
1596
1597 @clear_mutation_cache
1598 def copy(self, as_view=False):

Callers 4

to_numpy_arrayFunction · 0.80
to_scipy_sparse_arrayFunction · 0.80
induced_subgraphFunction · 0.80
get_all_simple_pathsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected