grinpy.functions.are_neighbors(G, v, nbunch)

Returns true if v is adjacent to any of the nodes in nbunch. Otherwise, returns false.

G : graph
A NetworkX graph.
v : node
A node in the graph.

nbunch : a single node or iterable container

isNeighbor : bool

If nbunch in a single node, True if v in a neighbor that node and False otherwise.

If nbunch is an interable, True if v is a neighbor of some node in nbunch and False otherwise.

>>> G = nx.star_graph(3) # Star on 4 nodes
>>> nx.are_neighbors(G, 0, 1)
>>> nx.are_neighbors(G, 1, 2)
>>> nx.are_neighbors(G, 1, [0, 2])