| 63 | |
| 64 | |
| 65 | class Graph{ |
| 66 | int v; |
| 67 | List<ArrayList<AdjNode>> adjList; |
| 68 | Graph(int v){ |
| 69 | this.v = v; |
| 70 | adjList = new ArrayList<>(); |
| 71 | for(int i = 0; i < this.v; i++){ |
| 72 | adjList.add(new ArrayList<>()); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | public void addEdge(int u, int v, int cost){ |
| 77 | this.adjList.get(u).add(new AdjNode(u, v, cost)); |
| 78 | this.adjList.get(v).add(new AdjNode(v, u, cost)); |
| 79 | } |
| 80 | public void printGraph(){ |
| 81 | for(int i = 0 ; i < this.v ; i++){ |
| 82 | System. out.print(i + " -> "); |
| 83 | for(int j = 0 ; j < adjList.get(i).size(); j++){ |
| 84 | System.out.print(adjList.get(i).get(j).dest + " "); |
| 85 | } |
| 86 | System. out.println(); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | class AdjNode{ |
| 92 | int source, dest, cost; |
nothing calls this directly
no outgoing calls
no test coverage detected