GraphTheory[HasArc]
GraphTheory[HasEdge]
|
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
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
>
|
|
| (6) |
>
|
|
| (7) |
>
|
|
| (8) |
|
|
Download Help Document
Was this information helpful?