@@ -73,7 +73,7 @@ public class DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<St
7373 private List <List <Integer >> in ;
7474 private List <List <Integer >> out ;
7575
76- private int numLinks = 0 ;
76+ private long numLinks = 0 ;
7777 private long modCount = 0 ;
7878
7979 // * changes for any edit which causes the node indices to change
@@ -85,7 +85,7 @@ public class DiskDGraph implements DGraph<String>, FastWalkable<String, DNode<St
8585 private Long hashMod = null ;
8686
8787 private boolean sorted = false ;
88-
88+
8989 public DiskDGraph (File dir )
9090 {
9191 this (dir , false );
@@ -94,7 +94,7 @@ public DiskDGraph(File dir)
9494 /**
9595 *
9696 * @param dbFile The file containing the graph structure. If the file doesn't exist,
97- * it will be created. IF it does exist, the graph it contains will be loaded.
97+ * it will be created. If it does exist, the graph it contains will be loaded.
9898 * @param nullLabels If true, all labels will be null (saving some space).
9999 * Adding a node with a nonnull label will result in an exception.
100100 */
@@ -126,7 +126,7 @@ public int size()
126126 }
127127
128128 @ Override
129- public int numLinks ()
129+ public long numLinks ()
130130 {
131131 return numLinks ;
132132 }
@@ -827,14 +827,22 @@ public List<? extends DNode<String>> nodes()
827827 return new NodeList (Series .series (size ()));
828828 }
829829
830+ /**
831+ * NOTE: If hasLongNumLinks is true and the graph has more links than
832+ * Integer.MAX_VALUE, the {size()} of the returned collection
833+ * will be -1.
834+ *
835+ * @return
836+ */
830837 @ Override
831- public Collection <? extends DLink <String >> links ()
838+ public Iterable <? extends DLink <String >> links ()
832839 {
833840 return new LinkCollection ();
834841 }
835842
836843 /**
837844 * A collection of all links in this graph.
845+ * The iterator it returns can be safely used.
838846 *
839847 * @author Peter
840848 *
@@ -850,7 +858,7 @@ public Iterator<DLink<String>> iterator()
850858 @ Override
851859 public int size ()
852860 {
853- return numLinks ;
861+ return ( int ) numLinks () ;
854862 }
855863
856864 private class LLIterator implements Iterator <DLink <String >>
@@ -1265,7 +1273,8 @@ public static DiskDGraph fromFile(File file, File tmpDir, File dbFile)
12651273
12661274 public void close ()
12671275 {
1268- db .atomicInteger ("numLinks" ).createOrOpen ().set (numLinks );
1276+ db .atomicLong ("numLinks" ).createOrOpen ().set (numLinks );
1277+
12691278 db .close ();
12701279 }
12711280
0 commit comments