Question: import java.util.*; class Edge { int source ; int destination; int weight; public Edge(int source, int destination, int weight) { this.source = source; this.destination =

 import java.util.*; class Edge \{ int source ; int destination; intweight; public Edge(int source, int destination, int weight) \{ this.source = source;

import java.util.*; class Edge \{ int source ; int destination; int weight; public Edge(int source, int destination, int weight) \{ this.source = source; this.destination = destination; this.weight = weight; \} \} class Graph \{ int vertices; LinkedList>[] adjacencylist ; Graph(int vertices) \{ this.vertices = vertices; adjacencylist = new LinkedList[vertices]; for (int i=0;i i++ ) \{ adjacencylist [i]= new LinkedList >(); \} \} public void addEdge(int source, int destination, int weight ) \{ Edge edge = new Edge(source, destination, weight ) ; adjacencylist [source].addFirst (edge); \} public void printGraph() \{ for (int i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!