grinpy.functions.neighborhoods.closed_neighborhood

grinpy.functions.neighborhoods.closed_neighborhood(G, nbunch)

Return a list of all neighbors of the nodes in nbunch, including the nodes in nbunch.

Parameters:
  • G (NetworkX graph) – An undirected graph.
  • nbunch – A single node or iterable container
Returns:

A list containing all nodes that are a neighbor of some node in nbunch together with all nodes in nbunch.

Return type:

list

See also

neighborhood()

Examples

>>> G = nx.path_graph(3) # Path on 3 nodes
>>> nx.closed_neighborhood(G, 1)
[0, 1, 2]