July 2018
Beginner
202 pages
5h 4m
English
The aim is to adapt the implementation of the AdjacencyListGraph class to support weights on edges.
The steps should be the following:
ArrayList<Edge>[] adj;public AdjacencyListWeightedGraph(int nodes) { this.adj = new ArrayList[nodes]; for (int i = 0; i < nodes; i++) this.adj[i] = new ArrayList<>();}public void addEdge(int u, int v, int weight) { this.adj[u].add(new Edge(u, v, weight));}
Read now
Unlock full access