Site Search:

maze quiz 11

public class Graph {
    private int V;
    private int E;
    private Set<Integer>[] adj;
    public int V() {return V;}
    public int E() {return E;}
    public Graph(int V) {
        this.V = V;
        this.E = 0;
        adj = (Set<Integer>[])new HashSet[V];
        for(int i = 0; i < V; i++) {
            adj[i] = new HashSet<Integer>();
        }
    }
    public addEdge(int v, int w) {
        adj[v].add(w);
        //what is missing here?
        E++;
    }
    public Iterator<Integer> adj(int v) {return adj[v];}
   
}