HasArc - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

GraphTheory

 HasArc
 check if digraph contains specified arc
 HasEdge
 check if graph contains specified edge

 Calling Sequence HasArc(G, e) HasArc(G, a) HasEdge(G, e) HasEdge(G, a)

Parameters

 G - graph e - edge - a set of two vertices in G a - arc (directed edge) - a list of two vertices in G

Description

 • 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.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{3,4\right\},\left\{4,1\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 4 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{HasEdge}\left(G,\left\{1,2\right\}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{HasEdge}\left(G,\left[2,1\right]\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{HasEdge}\left(G,\left\{1,3\right\}\right)$
 ${\mathrm{false}}$ (4)
 > $N≔\mathrm{Graph}\left(\left\{\left[1,2\right],\left[2,3\right],\left[3,4\right],\left[4,1\right]\right\}\right)$
 ${N}{≔}{\mathrm{Graph 2: a directed graph with 4 vertices and 4 arc\left(s\right)}}$ (5)
 > $\mathrm{HasArc}\left(N,\left[1,2\right]\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{HasArc}\left(N,\left[2,1\right]\right)$
 ${\mathrm{false}}$ (7)
 > $\mathrm{HasEdge}\left(G,\left[1,3\right]\right)$
 ${\mathrm{false}}$ (8)