GraphTheory
HasArc
check if digraph contains specified arc
HasEdge
check if graph contains specified edge
Calling Sequence
Parameters
Description
Examples
HasArc(G, e)
HasArc(G, a)
HasEdge(G, e)
HasEdge(G, a)
G
-
graph
e
edge - a set of two vertices in G
a
arc (directed edge) - a list of two vertices in G
If e = {u,v} then HasEdge(G,e) returns true if the undirected graph G contains the (undirected) edge {u,v}, and false otherwise.
If a = [u,v], a directed edge, HasEdge(G,a) returns true if the undirected graph G has the undirected edge {u,v} in it.
If a = [u,v], HasArc(G,a) returns true if the directed graph G has the directed edge from vertex u to v in it, and false otherwise.
If e = {u,v}, HasArc(G,a) returns true if the directed graph G has both edges [u,v] and [v,u] in it, and false otherwise.
Because the data structure for a graph is an array of sets of neighbors, the test for edge membership uses binary search and hence the cost is O(log k) where k is the number of neighbors.
with⁡GraphTheory:
G≔Graph⁡1,2,1,4,2,3,3,4
G≔Graph 1: an undirected graph with 4 vertices and 4 edge(s)
HasEdge⁡G,1,2
true
HasEdge⁡G,2,1
HasEdge⁡G,1,3
false
N≔Graph⁡1,2,2,3,3,4,4,1
N≔Graph 2: a directed graph with 4 vertices and 4 arc(s)
HasArc⁡N,1,2
HasArc⁡N,2,1
See Also
AddArc
AddEdge
DeleteArc
DeleteEdge
Graph
HighlightEdges
Download Help Document