Adjacency { (@ protected Adjacency myparent = null; public void set_myparent (Adjacency a) { myparent = a; } public Adjacency get_myparent() { return myparent; } @) } PrintAdjVisitor{ (@ void before (Adjacency host) { Adjacency p = host.get_myparent(); if (p!=null) System.out.println(p.get_source().get_vertex_name()); } @) } CheckCycleVisitor{ (@ boolean pass = true; Set aSet = new HashSet(); void before (Adjacency host) { Adjacency adjTemp = host.get_myparent(); //Assuming there is a single inheritance boolean cycle = false; while (adjTemp != null) { if (aSet.contains(adjTemp)) { cycle = true; break; } else { aSet.add(adjTemp); adjTemp = adjTemp.get_myparent(); } } if (cycle) { System.out.println("Class "+host.get_source().get_vertex_name()+" has cycle."); pass = false; } aSet.clear(); } public boolean isPass() { return pass; } @) } SetParentVisitor { (@ protected TraversalGraph tg = new TraversalGraph("from Cd_graph bypassing {->*,myparent,*} to Adjacency",Main.cg1); protected List adjList = Main.cg1.gather(Main.m, "from Cd_graph to Adjacency"); void before (Adjacency host) { List aList = Main.cg1.gather(host, "from Adjacency through Term_Bar_list to Vertex"); Ident host_i= host.get_source().get_vertex_name(); Iterator iList = aList.iterator(); while (iList.hasNext()) { Ident i = ((Vertex)iList.next()).get_vertex_name(); Iterator iadjList = adjList.iterator(); while (iadjList.hasNext()) { Adjacency a = (Adjacency) iadjList.next(); if (i.equals(a.get_source().get_vertex_name())) a.set_myparent(host); } } } @) }