MCPcopy Create free account
hub / github.com/LFYSec/MScan / Graph

Class Graph

src/test/resources/dataflow/livevar/Graph.java:4–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import java.util.List;
3
4public class Graph {
5 private static final String NEWLINE = System.getProperty("line.separator");
6
7 public final int V;
8 public int E;
9 public List<Integer>[] adj;
10
11 public Graph(int V) {
12 this.V = V;
13 this.E = 0;
14 adj = new List<Integer>[V];
15 for (int v = 0; v < V; v++) {
16 adj[v] = new ArrayList<Integer>();
17 }
18 }
19
20 public void addEdge(int v, int w) {
21 E++;
22 adj[v].add(w);
23 adj[w].add(v);
24 }
25
26 public String toString() {
27 StringBuilder s = new StringBuilder();
28 s.append(V + " vertices, " + E + " edges " + NEWLINE);
29 for (int v = 0; v < V; v++) {
30 s.append(v + ": ");
31 for (int w : adj[v]) {
32 s.append(w + " ");
33 }
34 s.append(NEWLINE);
35 }
36 return s.toString();
37 }
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected