Commit f0714d70 authored by Robin's avatar Robin Committed by Peter

Fixed spelling mistake Princton->Princeton (#1199)

* Fixed spelling mistake

* Fixed some checkstyle issues
parent c64fc418
......@@ -25,20 +25,20 @@ import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Data taken from here http://algs4.cs.princeton.edu/44sp/
* <p>
* This reader implementation allows to read graph definitions from text files in the format used on
* http://algs4.cs.princeton.edu/44sp/.
*
* @author Peter Karich
*/
public class PrinctonReader {
private Graph g;
public class PrincetonReader {
private Graph graph;
private InputStream is;
public PrinctonReader(Graph graph) {
g = graph;
public PrincetonReader(Graph graph) {
this.graph = graph;
}
public PrinctonReader setStream(InputStream is) {
public PrincetonReader setStream(InputStream is) {
this.is = is;
return this;
}
......@@ -57,7 +57,7 @@ public class PrinctonReader {
if (line == null)
throw new IllegalStateException("Cannot read line " + lineNo);
String args[] = line.split(" ");
String[] args = line.split(" ");
int from = -1;
int to = -1;
double dist = -1;
......@@ -81,7 +81,7 @@ public class PrinctonReader {
throw new RuntimeException("incorrect read!? from:" + from + ", to:" + to + ", dist:" + dist);
}
g.edge(from, to, dist, false);
graph.edge(from, to, dist, false);
}
} catch (Exception ex) {
throw new RuntimeException("Problem in line " + lineNo, ex);
......
......@@ -32,16 +32,18 @@ import static com.graphhopper.util.GHUtility.count;
import static org.junit.Assert.assertEquals;
/**
* The data is taken from https://algs4.cs.princeton.edu/44sp/.
*
* @author Peter Karich
*/
public class PrinctonReaderTest {
public class PrincetonReaderTest {
private EncodingManager encodingManager = new EncodingManager("car");
private EdgeFilter carOutEdges = new DefaultEdgeFilter(encodingManager.getEncoder("car"), false, true);
@Test
public void testRead() {
Graph graph = new GraphBuilder(encodingManager).create();
new PrinctonReader(graph).setStream(PrinctonReader.class.getResourceAsStream("tinyEWD.txt")).read();
new PrincetonReader(graph).setStream(PrincetonReader.class.getResourceAsStream("tinyEWD.txt")).read();
assertEquals(8, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(2, count(explorer.setBaseNode(0)));
......@@ -51,7 +53,7 @@ public class PrinctonReaderTest {
@Test
public void testMediumRead() throws IOException {
Graph graph = new GraphBuilder(encodingManager).create();
new PrinctonReader(graph).setStream(new GZIPInputStream(PrinctonReader.class.getResourceAsStream("mediumEWD.txt.gz"))).read();
new PrincetonReader(graph).setStream(new GZIPInputStream(PrincetonReader.class.getResourceAsStream("mediumEWD.txt.gz"))).read();
assertEquals(250, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(13, count(explorer.setBaseNode(244)));
......
......@@ -18,7 +18,7 @@
package com.graphhopper.routing;
import com.graphhopper.GraphHopper;
import com.graphhopper.reader.PrinctonReader;
import com.graphhopper.reader.PrincetonReader;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.routing.util.HintsMap;
......@@ -130,7 +130,7 @@ public class RoutingAlgorithmIT {
final GraphHopperStorage graph = new GraphBuilder(eManager).create();
String bigFile = "10000EWD.txt.gz";
new PrinctonReader(graph).setStream(new GZIPInputStream(PrinctonReader.class.getResourceAsStream(bigFile))).read();
new PrincetonReader(graph).setStream(new GZIPInputStream(PrincetonReader.class.getResourceAsStream(bigFile))).read();
GraphHopper hopper = new GraphHopper() {
{
setCHEnabled(false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment