import EDU.neu.ccs.demeter.dj.*; import com.objectspace.jgl.*; import com.objectspace.jgl.algorithms.*; import java.util.*; class Main { public static void main(String[] args) { ClassGraph cg = new ClassGraph(); // constructed from *.java System.out.println(cg.version() + " = version"); // 5 people MyVector persons = new MyVector(); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); persons.addElement(new Person()); BusStop aBusStop = new BusStop(persons); MyVector busStops = new MyVector(); // 10 people busStops.addElement(aBusStop); busStops.addElement(aBusStop); // was not intended but should work MyVector buses = new MyVector(); buses.addElement(persons); buses.addElement(persons); BusRoute aBusRoute = new BusRoute(buses, busStops); // Strategy sg = new Strategy("from BusRoute through BusStop to Person"); // Strategy sg = new Strategy( // "from BusRoute bypassing {BusRoute,BusStop,Person} through BusStop bypassing {BusRoute,BusStop,Person} to Person"); // good one Strategy sg = new Strategy( "{BusRoute -> BusStop bypassing {BusRoute,BusStop,Person,-> *,buses,*} BusStop -> Person bypassing {BusRoute,BusStop,Person,-> *,buses,*}}"); // Strategy sg = new Strategy("from BusRoute through BusStop to BusRoute"); System.out.println(sg + " Strategy graph "); TraversalGraph tg = TraversalGraph.compute(cg, sg); Integer result = (Integer) tg.traverse(aBusRoute, new MyVisitor()); int r = result.intValue(); if (r==10) {System.out.println("SUCCESS");} else {System.out.println("FAILURE");}; System.out.println(" number of waiting persons = " + result); System.out.println ("Traversal Graph for from BusRoute through BusStop to Person"); System.out.println(tg); System.out.println ("Summarized Traversal Graph for from BusRoute through BusStop to Person"); System.out.println(tg.toClassGraph()); InputIterator beginDs = tg.start(aBusRoute); InputIterator endDs = tg.finish(aBusRoute); Printing.println(beginDs, endDs); Enumeration e = tg.elements(aBusRoute); while (e.hasMoreElements()) System.out.println(e.nextElement()); } }