Question: WGraph.java E8WGraph.java No Selection 1 import java.io.* 2 import java.util.* 3 class Edge( public int) nodes new int[2]; /The nodes connected by the edges/ public

 WGraph.java E8WGraph.java No Selection 1 import java.io.* 2 import java.util.* 3
class Edge( public int) nodes new int[2]; /The nodes connected by the
edges/ public Integer weight; /*Integer so we can use Comparator*/ Edge(int i,
int j, int w) this.nodes[e)i; this.nodes(1] j this.weightw; 10 12 14 public
class WGraph( 15 16 17 18 19 20 21 private ArrayList edges
= new ArrayList(); private ArrayList nodesnew ArrayList private int nb_nodes 8 private
Integer source; private Integer destination 0; WGraph) WGraph(WGraph graph) 26 for(Edge e:graph.edges)

WGraph.java E8WGraph.java No Selection 1 import java.io.* 2 import java.util.* 3 class Edge( public int) nodes new int[2]; /The nodes connected by the edges/ public Integer weight; /*Integer so we can use Comparator*/ Edge(int i, int j, int w) this.nodes[e)i; this.nodes(1] j this.weightw; 10 12 14 public class WGraph( 15 16 17 18 19 20 21 private ArrayList edges = new ArrayList(); private ArrayList nodesnew ArrayList private int nb_nodes 8 private Integer source; private Integer destination 0; WGraph) WGraph(WGraph graph) 26 for(Edge e:graph.edges) this.addEdge(new Edge(e.nodes[),e.nodes[1),e.weight)); this.source -graph.source; this.destinationgraph.destination; 30 31 WGraph (String file) throws RuntimeException ( try f Scanner f new Scanner(new File (file)); String) ln-f.nextLine().split("+ I*first line is the source and destinations/ this.sourceInteger.parseInt(Inte]) this.destination-Integer.parseInt(n1]) int number nodesInteger.parseInt(f.nextLine)) /second line is the number of nodes*/ 35 38 while (f.hasNext)) String) line f.nextline).split("\s+) /*Make sure there is 3 elements on the line/ if (line.length 3) continue

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!