Question: Please comment on the code below; try { BufferedReader reader = new BufferedReader ( new FileReader ( new File ( graphOneFilename ) ) ) ;

Please comment on the code below;
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(graphOneFilename)));
String graphString ="";
while (reader.ready()){
graphString += reader.readLine();
}
this.graphOne = this.graphOne.edgeListToGraph(graphString);
reader.close();
reader = new BufferedReader(new FileReader(new File(graphTwoFilename)));
graphString ="";
while (reader.ready()){
graphString += reader.readLine();
}
this.graphTwo = this.graphTwo.edgeListToGraph(graphString);
reader.close();
} catch (FileNotFoundException e){
System.err.println("File not found: "+ e.getMessage());
} catch (IOException e){
System.err.println("Error reading file: "+ e.getMessage());
}
int i =0;
while (this.graphOne.numVertices()< this.graphTwo.numVertices()){
this.graphOne.addVertex("dummyVertex"+ i++);
}
i =0;
while (this.graphTwo.numVertices()< this.graphOne.numVertices()){
this.graphTwo.addVertex("dummyVertex"+ 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 Programming Questions!