/* Graph class */ import java.awt.*; import java.io.*; import java.net.*; import java.util.*; public class Graph { Node nodes[]; Edge edges[]; Arrow arrows[]; int n_nodes, n_edges, n_arrows, arrow_status; int node_cnt, edge_cnt, arrow_cnt; int type; Node source_node; static int padding = 100; public static final int orig_colour = 1; public static final int inter_colour = 2; public static final int final_colour = 3; public Graph( int n_nodes, int n_edges, int arrow_status ) { this.n_nodes = n_nodes; this.n_edges = n_edges; this.arrow_status = arrow_status; //System.out.println( "New Graph " + n_nodes + " nodes, " + n_edges + " edges" ); n_arrows = n_edges; nodes = new Node[n_nodes]; edges = new Edge[n_edges]; arrows = new Arrow[n_arrows]; node_cnt = edge_cnt = arrow_cnt = 0; } public void Insert_Ans(Graphics g, int n_id) { int i; for (i = 0; i < node_cnt; i++) { if (nodes[i].Get_ID() == n_id) { nodes[i].Show_Ans(g); break; } } } /* public void Ani_Edge(Graphics g, int from, int to, int val) { int i, j, k; Color change_to; int start_id, end_id, num_arcs = 1; change_to = Color.black; for(i = 0; i < edge_cnt; i++) { if (edges[i].Get_Start() == from && edges[i].Get_End() == to) { switch(val) { case 1: change_to = Color.black; //original break; case 2: change_to = Color.yellow; //intermediate break; case 3: change_to = Color.red; //final break; default: break; } start_id = from; end_id = to; for( k = 0; k max_x ) max_x = x; x = nodes[i].Mid_Y(); if ( x > max_y ) max_y = x; } x_scale = (double)width / ( max_x + padding ); y_scale = (double)height/ ( max_y + padding ); nodes[0].Set_Scale( x_scale, y_scale ); for( i = 0; i< node_cnt; i++ ) { nodes[i].Draw_Node( g ); //System.out.println("draw node i = "+i); } for( i = 0; i< edge_cnt; i++ ) { start_id = edges[i].Get_Start(); end_id = edges[i].Get_End(); for( j = 0; j