Question 3: =========== The program below is a testing program for traversal strategies. It uses the AP Library but it uses the classes StrategyGraph and ClassGraph from DJ. The class graphs and strategy graphs are parsed from strings. Program MyMain.java: import EDU.neu.ccs.demeter.aplib.*; import EDU.neu.ccs.demeter.aplib.sg.*; import EDU.neu.ccs.demeter.aplib.cd.*; class MyMain { //args[0]-ClassGraph args[1]-StrategyGraph public static void main(String[] args) { if(args.length<2) { System.out.println("usage: java MyMain \"ClassGraph\" \"StrategyGraph\""); return; } //print the command System.out.println("java MyMain "+"\""+args[0]+"\" "+"\""+args[1]+"\""); System.out.println("output:\n"); ClassGraph cg = ClassGraph.fromString(args[0]); StrategyGraph sg = StrategyGraph.fromString(args[1]); if (sg == null || cg == null) { System.out.println("StategyGraph or ClassGraph failed to instantiate"); return; } System.out.println(); System.out.println("Class Graph"); System.out.println(cg.toString()); System.out.println(); System.out.println("Strategy Graph"); System.out.println(sg.toString()); System.out.println(); // The following name map defines the identity map NameMapI m=new NameMapI(){ public String get(String l){return l;} }; TraversalGraph tg = TraversalGraph.compute(cg,sg,m); if (tg != null) { System.out.println(tg.toString()); // cg.printTraversalEdges(tg, ... ); } } } Testing script to run the above program multiple times: #!bin/sh #sh run_test cd /proj/adaptive/www/course/exams/m-3360-f99/q3 javac MyMain.java java MyMain "A=X. X=B C. B:X|E. E=. C=." "from A through B to C" java MyMain "A=B1 C. B1=B D. B=[B1]. C=D. D=E F1. E=G. F1=F G. F=[F1]. G=." \ "from A through B through F to G" java MyMain "A:B. B=C. C=." "from A bypassing ->A,b,B to C" java MyMain "A=B. B=C. C=B A." "from B to C" java MyMain "A=B. B=C. C=B." "from A to-stop C" java MyMain "A=B B. B=C. C=." "from A to C" The tesing script produces the following output: java MyMain "A=X. X=B C. B:X|E. E=. C=." "from A through B to C" output: Class Graph A = X. X = B C extends B. B : X | E. E = extends B. C = . Strategy Graph { A -> { B } { B } -> C } source: A target: C Nodes: X: in copies {0, 1} C: in copies {1} B: in copies {0, 1} A: in copies {0} Edges: -> A,x,X: in copies {0} -> X,c,C: in copies {1} => B,X: in copies {0, 1} -> X,b,B: in copies {0, 1}, intercopy table {{0, 1}} java MyMain "A=B1 C. B1=B D. B=[B1]. C=D. D=E F1. E=G. F1=F G. F=[F1]. G=." "from A through B through F to G" output: Class Graph A = B1 C. B1 = B D. B = [ B1]. C = D. D = E F1. E = G. F1 = F G. F = [ F1]. G = . Strategy Graph { A -> { B } { B } -> { F } { F } -> G } source: A target: G Nodes: F1: in copies {1, 2} B1: in copies {0, 1} G: in copies {2} F: in copies {1, 2} D: in copies {1} B: in copies {0, 1} A: in copies {0} Edges: -> B,b1,B1: in copies {0, 1} -> B1,d,D: in copies {1} -> B1,b,B: in copies {0, 1}, intercopy table {{0, 1}} -> A,b1,B1: in copies {0} -> F1,f,F: in copies {1, 2}, intercopy table {{1, 2}} -> D,f1,F1: in copies {1} -> F1,g,G: in copies {2} -> F,f1,F1: in copies {1, 2} java MyMain "A:B. B=C. C=." "from A bypassing ->A,b,B to C" output: Class Graph A : B. B = C extends A. C = . Strategy Graph { A -> C bypassing -> A, b, B } source: A target: C Nodes: C: in copies {0} B: in copies {0} A: in copies {0} Edges: -> B,c,C: in copies {0} => A,B: in copies {0} java MyMain "A=B. B=C. C=B A." "from B to C" output: Class Graph A = B. B = C. C = B A. Strategy Graph { B -> C } source: B target: C Nodes: C: in copies {0} B: in copies {0} A: in copies {0} Edges: -> C,b,B: in copies {0} -> B,c,C: in copies {0} -> C,a,A: in copies {0} -> A,b,B: in copies {0} java MyMain "A=B. B=C. C=B." "from A to-stop C" output: Class Graph A = B. B = C. C = B. Strategy Graph { A -> C bypassing C } source: A target: C Nodes: C: in copies {0} B: in copies {0} A: in copies {0} Edges: -> B,c,C: in copies {0} -> A,b,B: in copies {0} java MyMain "A=B B. B=C. C=." "from A to C" output: Class Graph A = B B. B = C. C = . Strategy Graph { A -> C } source: A target: C Nodes: C: in copies {0} B: in copies {0} A: in copies {0} Edges: -> B,c,C: in copies {0} -> A,b1,B: in copies {0} Answer the following: Describe a systematic approach on how to translate the traversal graphs shown here into Java traversal code and apply your approach to the first two cases: java MyMain "A=X. X=B C. B:X|E. E=. C=." "from A through B to C" java MyMain "A=B1 C. B1=B D. B=[B1]. C=D. D=E F1. E=G. F1=F G. F=[F1]. G=." \ "from A through B through F to G" In other words, give the detailed traversal code in Java for those two inputs.