A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://networkx.org/documentation/stable/reference/classes/generated/networkx.Graph.neighbors.html below:

Graph.neighbors — NetworkX 3.5 documentation

Graph.neighbors#
Graph.neighbors(n)[source]#

Returns an iterator over all neighbors of node n.

This is identical to iter(G[n])

Parameters:
nnode

A node in the graph

Returns:
neighborsiterator

An iterator over all neighbors of node n

Raises:
NetworkXError

If the node n is not in the graph.

Notes

Alternate ways to access the neighbors are G.adj[n] or G[n]:

>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_edge("a", "b", weight=7)
>>> G["a"]
AtlasView({'b': {'weight': 7}})
>>> G = nx.path_graph(4)
>>> [n for n in G[0]]
[1]

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> [n for n in G.neighbors(0)]
[1]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4