MCPcopy Create free account
hub / github.com/alibaba/GraphScope / has_edge

Method has_edge

python/graphscope/nx/classes/graph.py:1239–1278  ·  view source on GitHub ↗

Returns True if the edge (u, v) is in the graph. This is the same as `v in G[u]` without KeyError exceptions. Parameters ---------- u, v : nodes Nodes can be, for example, strings or numbers. Nodes must be int, str, float, tuple, bool hashab

(self, u, v)

Source from the content-addressed store, hash-verified

1237
1238 @clear_mutation_cache
1239 def has_edge(self, u, v):
1240 """Returns True if the edge (u, v) is in the graph.
1241
1242 This is the same as `v in G[u]` without KeyError exceptions.
1243
1244 Parameters
1245 ----------
1246 u, v : nodes
1247 Nodes can be, for example, strings or numbers.
1248 Nodes must be int, str, float, tuple, bool hashable Python objects.
1249
1250 Returns
1251 -------
1252 edge_ind : bool
1253 True if edge is in the graph, False otherwise.
1254
1255 Examples
1256 --------
1257 >>> G = nx.path_graph(4) # or DiGraph
1258 >>> G.has_edge(0, 1) # using two nodes
1259 True
1260 >>> e = (0, 1)
1261 >>> G.has_edge(*e) # e is a 2-tuple (u, v)
1262 True
1263 >>> e = (0, 1, {"weight": 7})
1264 >>> G.has_edge(*e[:2]) # e is a 3-tuple (u, v, data_dictionary)
1265 True
1266
1267 The following syntax are equivalent:
1268
1269 >>> G.has_edge(0, 1)
1270 True
1271 >>> 1 in G[0] # though this gives KeyError if 0 not in G
1272 True
1273
1274 """
1275 try:
1276 return v in self._adj[u]
1277 except KeyError:
1278 return False
1279
1280 @clear_mutation_cache
1281 def neighbors(self, n):

Callers 13

number_of_edgesMethod · 0.95
get_edge_dataMethod · 0.95
watts_strogatz_graphFunction · 0.95
__contains__Method · 0.80
has_successorMethod · 0.80
has_predecessorMethod · 0.80
test_subclassMethod · 0.80
powerlaw_cluster_graphFunction · 0.80

Calls

no outgoing calls