catch(Exception ex) { ex.printStackTrace(); }              int tmpEdges[], noOfEdgesOfNode[]=new int[m_nodes.size()]; int noOfPrntsOfNode[]=new int[m_nodes.size()]; for(int i=0; i<m_edges.size(); i++) { GraphEdge e = (GraphEdge)m_edges.elementAt(i); noOfEdgesOfNode[e.src]++; noOfPrntsOfNode[e.dest]++; } for(int i=0; i<m_edges.size(); i++) { GraphEdge e  = (GraphEdge)m_edges.elementAt(i); GraphNode n  = (GraphNode)m_nodes.elementAt(e.src); GraphNode n2 = (GraphNode)m_nodes.elementAt(e.dest); if(n.edges==null) { n.edges = new int[noOfEdgesOfNode[e.src]][2]; for(int k=0; k<n.edges.length; k++) n.edges[k][1]=0; } if(n2.prnts==null) { n2.prnts = new int[noOfPrntsOfNode[e.dest]]; for(int k=0; k<n2.prnts.length; k++) n2.prnts[k]=-1; } int k=0; while(n.edges[k][1]!=0) k++; n.edges[k][0] = e.dest; n.edges[k][1] = e.type;  k=0; while(n2.prnts[k]!=-1) k++; n2.prnts[k] = e.src; } }
    protected void graph(StreamTokenizer tk) {	try {	    tk.nextToken();	    	    if(tk.ttype==tk.TT_WORD) {		if(tk.sval.equalsIgnoreCase("digraph")) {		    tk.nextToken();  		    if(tk.ttype==tk.TT_WORD) {			m_graphName = tk.sval;			tk.nextToken();		    }		    		    while(tk.ttype!='{') {			System.err.println("Error at line "+tk.lineno()+" ignoring token "+tk.sval);			tk.nextToken();			if(tk.ttype==tk.TT_EOF)			    return;		    }		    stmtList(tk);		}		else if(tk.sval.equalsIgnoreCase("graph"))		    System.err.println("Error. Undirected graphs cannot be used");		else		    System.err.println("Error. Expected graph or digraph at line "+tk.lineno());	    }	}	catch(Exception ex) { ex.printStackTrace(); }	//int tmpMatrix[][] = new int[m_nodes.size()][m_nodes.size()];	//for(int i=0; i<m_edges.size(); i++)	//    tmpMatrix[((GraphEdge)m_edges.elementAt(i)).src]	//	     [((GraphEdge)m_edges.elementAt(i)).dest] = ((GraphEdge)m_edges.elementAt(i)).type;	//for(int i=0; i<m_nodes.size(); i++) {	//    GraphNode n = (GraphNode)m_nodes.elementAt(i);	//    n.edges = tmpMatrix[i];	//}	//Adding parents, and those edges to a node which are coming out from it	int tmpEdges[], noOfEdgesOfNode[]=new int[m_nodes.size()], noOfPrntsOfNode[]=new int[m_nodes.size()];	for(int i=0; i<m_edges.size(); i++) {	    GraphEdge e = (GraphEdge)m_edges.elementAt(i);	    noOfEdgesOfNode[e.src]++;	    noOfPrntsOfNode[e.dest]++;	}	for(int i=0; i<m_edges.size(); i++) {	    GraphEdge e  = (GraphEdge)m_edges.elementAt(i);	    GraphNode n  = (GraphNode)m_nodes.elementAt(e.src);	    GraphNode n2 = (GraphNode)m_nodes.elementAt(e.dest);	    if(n.edges==null) {		n.edges = new int[noOfEdgesOfNode[e.src]][2];		for(int k=0; k<n.edges.length; k++)		    n.edges[k][1]=0;	    }	    if(n2.prnts==null) {		n2.prnts = new int[noOfPrntsOfNode[e.dest]];		for(int k=0; k<n2.prnts.length; k++)		    n2.prnts[k]=-1;	    }	    int k=0;	    while(n.edges[k][1]!=0) k++;	    n.edges[k][0] = e.dest;	    n.edges[k][1] = e.type;	    	    k=0;	    while(n2.prnts[k]!=-1) k++;	    n2.prnts[k] = e.src;	    	}    }