Adds the given edge to the graph, increasing the number of nodes if needed.
Adds the given edge to the graph, increasing the number of nodes if needed.
Called by other methods when given an id that doesn't exist in this graph.
Called by other methods when given an id that doesn't exist in this graph. By default it throws an exception, but implementations can override it to return an IndexedSeq which is the neighbor seq of non-existing nodes (typically an empty IndexedSeq).
The number of edges in this graph.
The number of edges in this graph.
Increases maxNodeId and creates neighborless nodes as needed to ensure the given id is a valid id.
Returns the number of in-neighbors of the given id.
Returns the number of in-neighbors of the given id.
Returns the in-degree of the given node id, or 0 if the node id does not exist.
Returns the in-degree of the given node id, or 0 if the node id does not exist.
Returns the ith in-neighbor of the node with the given id.
Returns the ith in-neighbor of the node with the given id. Throws IndexOutOfBoundsException unless 0 <= i < inDegree(id).
Returns the in-neighbors of the given id as a java.util.List.
Returns the in-neighbors of the given id as a java.util.List.
Returns the in-neighbors of the given id.
Returns the in-neighbors of the given id.
Loads the underlying memory mapped file to RAM (if it isn't already in RAM), to improve the speed of subsequent reads.
The largest node id in this graph (or an upper bound on it).
The largest node id in this graph (or an upper bound on it).
Returns the nodeCount if it is defined.
Returns the nodeCount if it is defined. Otherwise throws an UnsupportedOperationException.
The number of nodes in this graph.
The number of nodes in this graph. May return None if it is expensive to compute (for example, for the union of two graphs).
All nodeIds that exist in the graph.
All nodeIds that exist in the graph.
Returns the number of out-neighbors of the given id.
Returns the number of out-neighbors of the given id.
Returns the out-degree of the given node id, or 0 if the node id does not exist.
Returns the out-degree of the given node id, or 0 if the node id does not exist.
Returns the ith out-neighbor of the node with the given id.
Returns the ith out-neighbor of the node with the given id. Throws IndexOutOfBoundsException unless 0 <= i < outDegree(id).
Returns the out-neighbors of the given id as a java.util.List.
Returns the out-neighbors of the given id as a java.util.List.
Returns the out-neighbors of the given id.
Returns the out-neighbors of the given id.
Syncs all data to disk and blocks until that completes.
Returns a view of the transpose of this graph.
Returns a view of the transpose of this graph.
Returns the node with the given id
or else None
if the given node does not
exist in this graph.
Returns the node with the given id
or else None
if the given node does not
exist in this graph. Deprecated: to decrease the number of objects used, get node
neighbors and degrees directly through the graph.
(Since version 1.0) Rather than using Node objects, use graph method directly
A graph which stores edge data in a memory mapped file. There is no object overhead per node: the memory used for with both in-neighbor and out-neighbor access is 8 bytes per edge and 24 bytes per node. Loading is very fast because no parsing of text is required. Loading time is exactly the time it takes the operating system to page data from disk into memory. Nodes are numbered sequentially from 0 to maxNodeId, and when a node id greater than maxNodeId is added, empty nodes are created as needed (i.e. nodeCount == maxNodeId + 1).
If given an empty file, this class creates a new empty graph which will store new nodes and edges in that file. If a MemMappedDynamicDirectedGraph is later created from the same file, it will contain the added nodes and edges. Graphs can also converted to dynamic binary format using MemMappedDynamicDirectedGraphConverter, then loaded using this class.
Concurrent reading threads are safe, but concurrent reading and writing is not currently supported.
If parameter syncAllWrites is true, all writes are immediately written to disk during each addEdges call. If syncAllWrites is set to false, write performance will improve, but the graph may be in an inconsistent state if the OS crashes or the machine loses power.
The binary format is currently subject to change.