MCPcopy
hub / github.com/networkx/networkx / remove_edge

Method remove_edge

networkx/classes/graph.py:1118–1150  ·  view source on GitHub ↗

Remove the edge between u and v. Parameters ---------- u, v : nodes Remove the edge between nodes u and v. Raises ------ NetworkXError If there is not an edge between u and v. See Also -------- remove_

(self, u, v)

Source from the content-addressed store, hash-verified

1116 nx._clear_cache(self)
1117
1118 def remove_edge(self, u, v):
1119 """Remove the edge between u and v.
1120
1121 Parameters
1122 ----------
1123 u, v : nodes
1124 Remove the edge between nodes u and v.
1125
1126 Raises
1127 ------
1128 NetworkXError
1129 If there is not an edge between u and v.
1130
1131 See Also
1132 --------
1133 remove_edges_from : remove a collection of edges
1134
1135 Examples
1136 --------
1137 >>> G = nx.path_graph(4) # or DiGraph, etc
1138 >>> G.remove_edge(0, 1)
1139 >>> e = (1, 2)
1140 >>> G.remove_edge(*e) # unpacks e from an edge tuple
1141 >>> e = (2, 3, {"weight": 7}) # an edge with attribute data
1142 >>> G.remove_edge(*e[:2]) # select first part of edge tuple
1143 """
1144 try:
1145 del self._adj[u][v]
1146 if u != v: # self-loop needs only one entry removed
1147 del self._adj[v][u]
1148 except KeyError as err:
1149 raise NetworkXError(f"The edge {u}-{v} is not in the graph") from err
1150 nx._clear_cache(self)
1151
1152 def remove_edges_from(self, ebunch):
1153 """Remove all edges specified in ebunch.

Callers 15

chordless_cyclesFunction · 0.95
get_counterexampleFunction · 0.95
test_cut_same_labelsMethod · 0.95
test_s_t_blossomMethod · 0.95
test_compMethod · 0.95
check_counterexampleFunction · 0.95

Calls 1

NetworkXErrorClass · 0.90