isReachable -- checks if a vertex u is reachable from a vertex v

Synopsis

• Usage:
r = isReachable(D, u, v)
• Inputs:
• D, an instance of the type Digraph,
• u, , this is the vertex that we are attempting to reach
• v, , this is the vertex that we are starting from
• Outputs:
• r, , whether or not us is reachable from v

Description

In a Digraph D, a vertex u of D is reachable from another vertex v of D if u is a descendant of v. Alternatively, u is reachable from v if there is some set of vertices u_0, ... , u_n such that u_n = u and u_0 = v and (u_i, u_i+1) is and edge of D for all i from 0 to n-1.

 i1 : D = digraph({a,b,c,d,e},{{a,b},{b,c},{b,d},{e,b}}); i2 : isReachable(D, e, a) o2 = false i3 : isReachable(D, d, e) o3 = true