// To use this class, simply call ReadGraph.readGraph(String filename) // somewhere in your code. This method returns a GraphInfo object which // has four members: // // name - the name of the graph (a String) // nNodes - the number of nodes (an integer) // nEdges - the number of edges (an integer) // edges - an array of EdgeInfo objects // // Each EdgeInfo object has two members, integers u and v, which are the // labels for the nodes on that edge. // // Note that this method doesn't actually construct the graph data structure. // You will need to do this yourself. This method simply extracts all of the // necessary data from the file, so you don't have to deal with I/O. // // Also note that the readGraph method returns null when either the file // is not found, or is improperly formatted. import java.io.*; import java.util.*; public class ReadGraph { public static GraphInfo readGraph(String filename) { GraphInfo g = new GraphInfo(); try { BufferedReader br = new BufferedReader(new FileReader(filename)); g.name = br.readLine(); g.nNodes = Integer.parseInt(br.readLine()); g.nEdges = Integer.parseInt(br.readLine()); g.edges = new EdgeInfo[g.nEdges]; for (int i=0; i