public class AdjacencyListGraph extends AbstractGraph
A lightweight graph class intended to allow the construction of big graphs (millions of elements).
The main purpose here is to minimize memory consumption even if the
management of such a graph implies more CPU consuming. See the
complexity
tags on each method so as to figure out the impact on
the CPU.
AbstractElement.AttributeChangeEvent
Replayable.Controller
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_EDGE_CAPACITY |
static int |
DEFAULT_NODE_CAPACITY |
static double |
GROW_FACTOR |
Constructor and Description |
---|
AdjacencyListGraph(java.lang.String id)
Creates an empty graph with strict checking and without auto-creation.
|
AdjacencyListGraph(java.lang.String id,
boolean strictChecking,
boolean autoCreate)
Creates an empty graph with default edge and node capacity.
|
AdjacencyListGraph(java.lang.String id,
boolean strictChecking,
boolean autoCreate,
int initialNodeCapacity,
int initialEdgeCapacity)
Creates an empty graph.
|
Modifier and Type | Method and Description |
---|---|
java.util.stream.Stream<Edge> |
edges() |
Edge |
getEdge(int index)
Get an edge by its index.
|
Edge |
getEdge(java.lang.String id)
Get an edge by its identifier.
|
int |
getEdgeCount()
Number of edges in this graph.
|
Node |
getNode(int index)
Get a node by its index.
|
Node |
getNode(java.lang.String id)
Get a node by its identifier.
|
int |
getNodeCount()
Number of nodes in this graph.
|
java.util.stream.Stream<Node> |
nodes() |
addAttributeSink, addEdge, addElementSink, addNode, addSink, attributeSinks, clear, clearAttributeSinks, clearElementSinks, clearSinks, display, display, edgeAdded, edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, edgeFactory, edgeRemoved, elementSinks, getReplayController, getStep, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, graphCleared, isAutoCreationEnabled, isStrict, iterator, nodeAdded, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved, nodeFactory, nodeRemoved, removeAttributeSink, removeEdge, removeEdge, removeElementSink, removeNode, removeSink, setAutoCreate, setEdgeFactory, setNodeFactory, setStrict, stepBegins, stepBegins
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, setAttribute, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
addEdge, addEdge, addEdge, addEdge, addEdge, read, read, removeEdge, removeEdge, removeEdge, removeEdge, removeNode, removeNode, write, write
attributeKeys, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, getLabel, getMap, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasLabel, hasMap, hasNumber, hasVector, removeAttribute, setAttribute, setAttributes
replay, tryReplay
public static final double GROW_FACTOR
public static final int DEFAULT_NODE_CAPACITY
public static final int DEFAULT_EDGE_CAPACITY
public AdjacencyListGraph(java.lang.String id, boolean strictChecking, boolean autoCreate, int initialNodeCapacity, int initialEdgeCapacity)
id
- Unique identifier of the graph.strictChecking
- If true any non-fatal error throws an exception.autoCreate
- If true (and strict checking is false), nodes are automatically
created when referenced when creating a edge, even if not yet
inserted in the graph.initialNodeCapacity
- Initial capacity of the node storage data structures. Use this if
you know the approximate maximum number of nodes of the graph. The
graph can grow beyond this limit, but storage reallocation is
expensive operation.initialEdgeCapacity
- Initial capacity of the edge storage data structures. Use this if
you know the approximate maximum number of edges of the graph. The
graph can grow beyond this limit, but storage reallocation is
expensive operation.public AdjacencyListGraph(java.lang.String id, boolean strictChecking, boolean autoCreate)
id
- Unique identifier of the graph.strictChecking
- If true any non-fatal error throws an exception.autoCreate
- If true (and strict checking is false), nodes are automatically
created when referenced when creating a edge, even if not yet
inserted in the graph.public AdjacencyListGraph(java.lang.String id)
id
- Unique identifier of the graph.public java.util.stream.Stream<Node> nodes()
public java.util.stream.Stream<Edge> edges()
public Edge getEdge(java.lang.String id)
Graph
ExtendedEdge edge = graph.getEdge("...");
the method will return an ExtendedEdge edge. If no left part exists, method will just return an Edge.
id
- Identifier of the edge to find.public Edge getEdge(int index)
Graph
ExtendedEdge edge = graph.getEdge(index);
the method will return an ExtendedEdge edge. If no left part exists, method will just return an Edge.
index
- The index of the edge to find.public int getEdgeCount()
Structure
public Node getNode(java.lang.String id)
Graph
ExtendedNode node = graph.getNode("...");
the method will return an ExtendedNode node. If no left part exists, method will just return a Node.
id
- Identifier of the node to find.public Node getNode(int index)
Graph
ExtendedNode node = graph.getNode(index);
the method will return an ExtendedNode node. If no left part exists, method will just return a Node.
index
- Index of the node to find.public int getNodeCount()
Structure