class Graph { ArrayList> adj; ArrayList> coords; int V; Graph(int v) { V = v; adj = new ArrayList>(V); coords = new ArrayList>(V); for (int i = 0; i < V; i++) { adj.add(new ArrayList()); coords.add(new ArrayList()); } } void draw_vis(boolean[] vis) { strokeWeight(20); stroke(255); for (int i = 0; i < coords.size(); i++) { if (!vis[i]) continue; point(coords.get(i).get(0), coords.get(i).get(1)); text(i+1, coords.get(i).get(0)-4, coords.get(i).get(1)+5); } } void draw_points(int point_weight) { strokeWeight(point_weight); stroke(#FF0000); for (int i = 0; i < coords.size(); i++) { point(coords.get(i).get(0), coords.get(i).get(1)); text(i+1, coords.get(i).get(0)-3, coords.get(i).get(1)+5); } } void draw_graph(int graph_weight, int point_weight) { stroke(#550000); strokeWeight(10); for (int i = 0; i < adj.size(); i++) { for (int idx = 0; idx < adj.get(i).size(); idx++) { int e = adj.get(i).get(idx); draw_arrow(coords.get(i).get(0), coords.get(i).get(1), coords.get(e).get(0), coords.get(e).get(1), point_weight, graph_weight); } } } void set_coords(int idx, int x, int y) { coords.get(idx).add(x); coords.get(idx).add(y); } void add_edge(int u, int v) { adj.get(u).add(v); } }