networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
has_edge(self, u, v, key=None)

This is the same as :None:None:`v in G[u] or key in G[u][v]` without KeyError exceptions.

Parameters

u, v : nodes

Nodes can be, for example, strings or numbers.

key : hashable identifier, optional (default=None)

If specified return True only if the edge with key is found.

Returns

edge_ind : bool

True if edge is in the graph, False otherwise.

Returns True if the graph has an edge between nodes u and v.

Examples

Can be called either using two nodes u, v, an edge tuple (u, v), or an edge tuple (u, v, key).

>>> G = nx.MultiGraph()  # or MultiDiGraph
... nx.add_path(G, [0, 1, 2, 3])
... G.has_edge(0, 1) # using two nodes True
>>> e = (0, 1)
... G.has_edge(*e) # e is a 2-tuple (u, v) True
>>> G.add_edge(0, 1, key="a")
'a'
>>> G.has_edge(0, 1, key="a")  # specify key
True
>>> G.has_edge(1, 0, key="a")  # edges aren't directed
True
>>> e = (0, 1, "a")
... G.has_edge(*e) # e is a 3-tuple (u, v, 'a') True

The following syntax are equivalent:

>>> G.has_edge(0, 1)
True
>>> 1 in G[0]  # though this gives :exc:`KeyError` if 0 not in G
True
>>> 0 in G[1]  # other order; also gives :exc:`KeyError` if 0 not in G
True
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.classes.multigraph.MultiGraph.has_edge

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/classes/multigraph.py#700
type: <class 'function'>
Commit: