Main { {{ static ClassGraph cg; public static void main(String args[]) throws Exception { Formula csp1 = Formula.parse(System.in); cg = new ClassGraph(true, false); System.out.println(); System.out.println("Constraint Satisfaction Problem to be processed "); csp1.print(); System.out.println(); Integer cI = (Integer) cg.traverse(csp1,"from Formula to Variable", new Visitor() { int c; public void start() {c=0;} public void before (Variable host) { c++;} public Object getReturnValue() {return new Integer(c);} }); System.out.println("number of Variable occurrences = " + cI); Float cF = (Float) cg.traverse(csp1,"from Formula to Weight", new Visitor() { float c; public void start() {c=0;} public void before (Weight host) { c = c + host.get_v();} public Object getReturnValue() {return new Float(c);} }); System.out.println("total Weight = " + cF); // TraversalGraph tg = new TraversalGraph("from Formula to Variable", cg); // System.out.println(tg); } }} } Formula { void print() to * (PrintVisitor); }