From 4f8f8ce5153fe0aac979a1afd6186c6027207a00 Mon Sep 17 00:00:00 2001 From: Peter Bloem Date: Thu, 10 Nov 2016 10:38:13 +0100 Subject: [PATCH] Bugfix in reading from file --- nodes/src/main/java/org/nodes/DiskDGraph.java | 2 +- .../test/java/org/nodes/DiskDGraphTest.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/nodes/src/main/java/org/nodes/DiskDGraph.java b/nodes/src/main/java/org/nodes/DiskDGraph.java index 45d1a8e..81416cc 100644 --- a/nodes/src/main/java/org/nodes/DiskDGraph.java +++ b/nodes/src/main/java/org/nodes/DiskDGraph.java @@ -1280,7 +1280,7 @@ private static long readSorted(List> list, File file, boolean forw long links = 0; - Integer current = null; + Integer current = 0; List neighbors = new ArrayList(); do diff --git a/nodes/src/test/java/org/nodes/DiskDGraphTest.java b/nodes/src/test/java/org/nodes/DiskDGraphTest.java index de24161..31d4266 100644 --- a/nodes/src/test/java/org/nodes/DiskDGraphTest.java +++ b/nodes/src/test/java/org/nodes/DiskDGraphTest.java @@ -649,6 +649,30 @@ public void testJBC() assertEquals(2, subgraph.numLinks()); } + @Test + public void degrees() + throws IOException + { + DGraph disk = DiskDGraph.fromFile(new File("/Users/Peter/Documents/Datasets/graphs/wikipedia-nl/wikipedia-nl-simple.txt"), new File("./tmp/")); + + DGraph mem = Data.edgeListDirectedUnlabeled(new File("/Users/Peter/Documents/Datasets/graphs/wikipedia-nl/wikipedia-nl-simple.txt"), true); + + assertEquals(disk.size(), mem.size()); + assertEquals(disk.numLinks(), mem.numLinks()); + + for(int i : series(disk.size())) + { + try { + assertEquals(mem.get(i).inDegree(), disk.get(i).inDegree()); + assertEquals(mem.get(i).outDegree(), disk.get(i).outDegree()); + } catch(AssertionError e) + { + System.out.println(i + " mem: " + mem.get(i).inDegree() + " " + mem.get(i).outDegree() + " disk:" + disk.get(i).inDegree() + " " + disk.get(i).outDegree() ); + } + } + } + + @After public void cleanup() {