Question: Write a SymbolGraph client like DegreesOfSeparation(the first picture) that uses depth-first search instead of breadth-first search to find paths connecting two performers, producing output like
Write a SymbolGraph client like DegreesOfSeparation(the first picture) that uses depth-first search instead of breadth-first search to find paths connecting two performers, producing output like the second picture. 

Degrees of separation public class Degrees0fSeparation public static void mai args SymbolGraph sg new SymbolGraph Cargs [0], args [1]) Graph G sg.GO String source args [2] if C!sg. contains (source) StdOut. println (source not in database return int s sg.1 ndex(source BreadthFirstPaths bfs new BreadthFirstPaths CG, s); while C! StdIn. isEmpty (D) String sink StdIn. readLine if Csg.contains (sink)) int t sg index (sink) if (bfs. has PathTo(t)) for (int v bfs pathTo(t)) StdOut. println sg. name (v)) else Stdout printin Not connected") else Stdout ot in database This symbolGraph and BreadthF client finds shortest paths in graphs. For movies.txt, it plays the Kevin Bacon game. java Degrees0fSeparation routes.txt JFK JFK ORD PHX LAS DFW JFK ORD Degrees of separation public class Degrees0fSeparation public static void mai args SymbolGraph sg new SymbolGraph Cargs [0], args [1]) Graph G sg.GO String source args [2] if C!sg. contains (source) StdOut. println (source not in database return int s sg.1 ndex(source BreadthFirstPaths bfs new BreadthFirstPaths CG, s); while C! StdIn. isEmpty (D) String sink StdIn. readLine if Csg.contains (sink)) int t sg index (sink) if (bfs. has PathTo(t)) for (int v bfs pathTo(t)) StdOut. println sg. name (v)) else Stdout printin Not connected") else Stdout ot in database This symbolGraph and BreadthF client finds shortest paths in graphs. For movies.txt, it plays the Kevin Bacon game. java Degrees0fSeparation routes.txt JFK JFK ORD PHX LAS DFW JFK ORD
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
