@@ -94,6 +94,8 @@ public DiskDGraph(File dir)
9494 */
9595 public DiskDGraph (File dir , boolean nullLabels )
9696 {
97+ this .nullLabels = nullLabels ;
98+
9799 dir .mkdirs ();
98100 File dbFile = new File (dir , "graph." +id +".db" );
99101
@@ -523,11 +525,11 @@ public List<DLink<String>> links()
523525
524526 List <DLink <String >> list = new ArrayList <DLink <String >>(degree ());
525527
526- for (int neighbor : out .get (index ))
528+ for (int neighbor : out .get (( int ) index ))
527529 list .add (new DiskDLink (index , neighbor ));
528530
529- for (int neighbor : in .get (index ))
530- if (neighbor != index ) // no double reflexive links
531+ for (int neighbor : in .get (( int ) index ))
532+ if (neighbor != (( int ) index ) ) // no double reflexive links
531533 list .add (new DiskDLink (neighbor , index ));
532534
533535 return list ;
@@ -539,7 +541,7 @@ public List<DLink<String>> linksOut()
539541 check ();
540542
541543 List <DLink <String >> list = new ArrayList <DLink <String >>(outDegree ());
542- for (int neighbor : out .get (index ))
544+ for (int neighbor : out .get (( int ) index ))
543545 list .add (new DiskDLink (index , neighbor ));
544546
545547 return list ;
@@ -551,7 +553,7 @@ public List<DLink<String>> linksIn()
551553 check ();
552554
553555 List <DLink <String >> list = new ArrayList <DLink <String >>(inDegree ());
554- for (int neighbor : in .get (index ))
556+ for (int neighbor : in .get (( int ) index ))
555557 list .add (new DiskDLink (neighbor , index ));
556558
557559 return list ;
@@ -565,12 +567,12 @@ public Collection<? extends DLink<String>> links(Node<String> other)
565567 List <DLink <String >> list = new ArrayList <DLink <String >>();
566568
567569 int o = other .index ();
568- for (int neighbor : out .get (index ))
570+ for (int neighbor : out .get (( int ) index ))
569571 if (neighbor == o )
570572 list .add (new DiskDLink (index , neighbor ));
571573
572574 if (index != o )
573- for (int neighbor : in .get (index ))
575+ for (int neighbor : in .get (( int ) index ))
574576 if (neighbor == o )
575577 list .add (new DiskDLink (neighbor , index ));
576578
@@ -585,8 +587,8 @@ public Collection<? extends DLink<String>> linksOut(DNode<String> other)
585587 List <DLink <String >> list = new ArrayList <DLink <String >>(outDegree ());
586588
587589 int o = other .index ();
588- for (int neighbor : out .get (index ))
589- if (neighbor == o )
590+ for (int neighbor : out .get (( int ) index ))
591+ if ((( int ) neighbor ) == (( int ) o ) )
590592 list .add (new DiskDLink (index , neighbor ));
591593
592594 return list ;
@@ -600,7 +602,7 @@ public Collection<? extends DLink<String>> linksIn(DNode<String> other)
600602 List <DLink <String >> list = new ArrayList <DLink <String >>(inDegree ());
601603
602604 int o = other .index ();
603- for (int neighbor : in .get (index ))
605+ for (int neighbor : in .get (( int ) index ))
604606 if (neighbor == o )
605607 list .add (new DiskDLink (neighbor , index ));
606608
@@ -612,7 +614,6 @@ private class DiskDLink implements DLink<String>
612614 {
613615 private DNode <String > from , to ;
614616
615-
616617 private long nodeModState = nodeModCount ;
617618
618619 private boolean dead = false ;
@@ -901,7 +902,7 @@ private void read()
901902 public DNode <String > add (String label )
902903 {
903904
904- if (! nullLabels && label != null )
905+ if (nullLabels && label != null )
905906 throw new IllegalArgumentException ("Graph is set to null labels only." );
906907
907908 if (! nullLabels )
@@ -1169,11 +1170,12 @@ public static DiskDGraph fromFile(File file, File dir)
11691170 // * sort the input file by first element
11701171 File forward = new File (dir , "forward.edgelist" );
11711172
1172- ExternalSort . mergeSortedFiles (
1173- ExternalSort .sortInBatch (
1173+
1174+ List < File > files = ExternalSort .sortInBatch (
11741175 file ,
11751176 new LComp (true ), ExternalSort .DEFAULTMAXTEMPFILES ,
1176- Charset .defaultCharset (), dir , false ), forward );
1177+ Charset .defaultCharset (), dir , false );
1178+ ExternalSort .mergeSortedFiles (files , forward , new LComp (true ), Charset .defaultCharset ());
11771179
11781180 System .out .println ("Forward sort finished" );
11791181
@@ -1184,11 +1186,11 @@ public static DiskDGraph fromFile(File file, File dir)
11841186 forward .delete ();
11851187 File backward = new File (dir , "backward.edgelist" );
11861188
1187- ExternalSort .mergeSortedFiles (
1188- ExternalSort .sortInBatch (
1189+ files = ExternalSort .sortInBatch (
11891190 file ,
11901191 new LComp (false ), ExternalSort .DEFAULTMAXTEMPFILES ,
1191- Charset .defaultCharset (), dir , false ), backward );
1192+ Charset .defaultCharset (), dir , false );
1193+ ExternalSort .mergeSortedFiles (files , backward , new LComp (false ), Charset .defaultCharset ());
11921194
11931195 System .out .println ("Backward sort finished" );
11941196
@@ -1272,9 +1274,17 @@ private static long readSorted(List<List<Integer>> list, File file, boolean forw
12721274
12731275 if (a != (int ) current )
12741276 {
1275- list .add (neighbors );
1277+ try {
1278+ list .add (neighbors );
1279+ } catch (AssertionError e )
1280+ {
1281+ throw new AssertionError ("Failed to add list to IndexTreeList. current list size: " +list .size ()+", list to be added " +neighbors );
1282+ }
12761283 neighbors .clear ();
12771284
1285+ if (a < list .size ())
1286+ throw new IllegalStateException ("Next index is " +a +", while list size is already " + list .size () + ". It seems like the sorting ot the file went wrong." );
1287+
12781288 while (list .size () < a )
12791289 list .add (Collections .EMPTY_LIST );
12801290
0 commit comments