Given the representation of a directed graph as an adjacency list (list of neighbors): >(setq graph '( (a b c ) (b a d )

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given the representation of a directed graph as an adjacency list (list of neighbors): >(setq graph '( (a b c ) (b a d )

Post by answerhappygod »

Given the representation of a directed graph as an adjacencylist (list of neighbors): >(setq graph '( (a b c ) (b a d ) (c ad e ) (d b c e g) (e c d f) (f e g) (g d f) ) ) where, the firstelement of each sub-list is the source node and the tail of thesub-list are its neighbors, (for example the sub-list (a b c) meansthere is a link from a to b and a link from a to c). >Write afunction to perform depth first search of a graph (call yourfunction dfs). The function should take as arguments: a graphdefined as above, the starting node for the search and the goalnode of the search. It should return as output the path found fromthe starting node to the goal node. For example, >(dfs graph 'a'g) returns (a b d c e f g) >(dfs graph ‘c ‘d) returns (c a bd
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply