Cd_graph { traversal allInh(CountingVisitor c) { to Vertex; // is incorrect; should be: // from Cd_graph via ? to Vertex } int countInhRels2() = allInh(CountingVisitor); (@ int countInhRels() { CountingVisitor count = new CountingVisitor(); this.allInh(count); return count.get_return_val(); } @) } CountingVisitor { init (@ total = 0; @) before Vertex (@ total = total +1; @) after {Cd_graph,Adj} (@ System.out.println("CountingVisitor is leaving " +host.getClass().toString() + " total = " + total); @) return int (@ total @) } Main { (@ static public void main(String args[]) throws Exception { Cd_graph graph = Cd_graph.parse(System.in); System.out.println("result = " + graph.countInhRels() + " , " + graph.countInhRels2()); } @) }