@Override public int nodes(String filename) { Filereader fr = new Filereader(filename); fr.readLine(); int N = Integer.parseInt(fr.readLine()); fr.close(); return N; }
@Override public void read(String filename, Graph graph) { Filereader fr = new Filereader(filename); // CLASS fr.readLine(); // KEY String key = fr.readLine(); // # MUDULUS this.modulus = Double.parseDouble(fr.readLine()); // # WRAP-AROUND this.wrapAround = Boolean.parseBoolean(fr.readLine()); // # PARTITIONS int partitions = Integer.parseInt(fr.readLine()); this.partitions = new RingPartition[partitions]; this.maxDistance = this.wrapAround ? this.modulus / 2.0 : this.modulus; // PARTITIONS String line = null; while ((line = fr.readLine()) != null) { String[] temp = line.split(":"); int index = Integer.parseInt(temp[0]); this.partitions[index] = new RingPartition(temp[1], this); } fr.close(); graph.addProperty(key, this); }
@Override public Graph read(String filename) { String delimiter = Config.get("GRAPH_WRITER_DELIMITER"); Filereader fr = new Filereader(filename); String name = fr.readLine(); int N = Integer.parseInt(fr.readLine()); int E = Integer.parseInt(fr.readLine()); Graph graph = new Graph(name); Node[] nodes = Node.init(N, graph); Edges edges = new Edges(nodes, E); String line = null; while ((line = fr.readLine()) != null) { String[] temp = line.split(delimiter); edges.add(Integer.parseInt(temp[0]), Integer.parseInt(temp[1])); } edges.fill(); graph.setNodes(nodes); fr.close(); return graph; }