Cd_graph{ (@ void flatten(){ String strategy = "from Cd_graph bypassing {-> *, superclass, *} to-stop Alternat_ns"; //Flatten the Cd_graph System.out.println("FlatteningVisitor"); FlatteningVisitor fv = new FlatteningVisitor(); Main.cg.traverse(this, strategy, fv); } @) } FlatteningVisitor{ (@ void before(Alternat_ns host){ String allAdjacencies = "from Cd_graph bypassing {-> *, superclass, *} to-stop Adjacency"; String subClassStrategy = "from Alternat_ns bypassing Any_vertex_List through Term_Bar_list to Vertex"; //get all the subclass vertices of the Alternat_ns, 'host' Iterator subClassIter = Main.cg.gather(host, subClassStrategy).iterator(); Any_vertex_List alist = host.get_construct_ns(); HashSet hash = new HashSet(); while(alist.hasMoreElements()){ hash.add(alist.nextElement()); } //Here, search for the adjacency whose source matches the subclass vertex object while(subClassIter.hasNext()){ //get the list of the Adjacency objects that we are going to search in order to find // the one whose source is the same as the subClassIter.next() Adjacency1Visitor adjv = new Adjacency1Visitor(); Main.cg.traverse(Main.cd, allAdjacencies, adjv); Vertex sub = (Vertex)subClassIter.next(); Iterator adjHash = adjv.getHashSet().iterator(); while(adjHash.hasNext()){ Adjacency adj = (Adjacency) adjHash.next(); String sourceName = adj.get_source().get_vertex_name().toString(); String subName = sub.get_vertex_name().toString(); //if equality exists, set the superclass part of the Adjacency, host if(sourceName.equals(subName)){ System.out.println(); //Get the Any_vertex_List associated with the Adjacency, adj AVListVisitor avlv = new AVListVisitor(); Main.cg.traverse(adj, "from Adjacency bypassing {-> *, superclass, *} to Any_vertex_List", avlv); Iterator iter = avlv.getHashSet().iterator(); if(iter.hasNext()){ Any_vertex_List adjVList = (Any_vertex_List)iter.next(); Iterator hostVList = hash.iterator(); while(hostVList.hasNext()){ adjVList.addElement((Any_vertex)hostVList.next()); } } } } } } @) } AVListVisitor{ (@ HashSet hash = new HashSet(); void before(Any_vertex_List host){ hash.add(host); } HashSet getHashSet(){ return hash; } @) }