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.
Modifier and Type | Class and Description |
---|---|
protected class |
AdjacencyListGraph.EdgeIterator<T extends Edge> |
protected class |
AdjacencyListGraph.NodeIterator<T extends Node> |
AbstractGraph.GraphReplayController
AbstractElement.AttributeChangeEvent
Replayable.Controller
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_EDGE_CAPACITY |
static int |
DEFAULT_NODE_CAPACITY |
protected AbstractEdge[] |
edgeArray |
protected int |
edgeCount |
protected HashMap<String,AbstractEdge> |
edgeMap |
static double |
GROW_FACTOR |
protected AbstractNode[] |
nodeArray |
protected int |
nodeCount |
protected HashMap<String,AbstractNode> |
nodeMap |
listeners
attributes, attributesBeingRemoved, id
Constructor and Description |
---|
AdjacencyListGraph(String id)
Creates an empty graph with strict checking and without auto-creation.
|
AdjacencyListGraph(String id,
boolean strictChecking,
boolean autoCreate)
Creates an empty graph with default edge and node capacity.
|
AdjacencyListGraph(String id,
boolean strictChecking,
boolean autoCreate,
int initialNodeCapacity,
int initialEdgeCapacity)
Creates an empty graph.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEdgeCallback(AbstractEdge edge)
This method is automatically called when a new edge is created.
|
protected void |
addNodeCallback(AbstractNode node)
This method is automatically called when a new node is created.
|
protected void |
clearCallback()
This method is automatically called when the graph is cleared.
|
<T extends Edge> |
getEdge(int index)
Get an edge by its index.
|
<T extends Edge> |
getEdge(String id)
Get an edge by its identifier.
|
int |
getEdgeCount()
Number of edges in this graph.
|
<T extends Edge> |
getEdgeIterator()
Iterator on the set of edges, in an undefined order.
|
<T extends Node> |
getNode(int index)
Get a node by its index.
|
<T extends Node> |
getNode(String id)
Get a node by its identifier.
|
int |
getNodeCount()
Number of nodes in this graph.
|
<T extends Node> |
getNodeIterator()
Iterator on the set of nodes, in an undefined order.
|
protected void |
removeEdgeCallback(AbstractEdge edge)
This method is automatically called when an edge is removed.
|
protected void |
removeNodeCallback(AbstractNode node)
This method is automatically called when a node is removed.
|
addAttributeSink, addEdge, addEdge, addEdge, addEdge, addEdge, addEdge, addEdge, addElementSink, addNode, addSink, attributeChanged, attributeSinks, clear, clearAttributeSinks, clearElementSinks, clearSinks, display, display, edgeAdded, edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, edgeFactory, edgeRemoved, elementSinks, getEachEdge, getEachNode, getEdgeSet, getNodeSet, getReplayController, getStep, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, graphCleared, isAutoCreationEnabled, isStrict, iterator, nodeAdded, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved, nodeFactory, nodeRemoved, nullAttributesAreErrors, read, read, removeAttributeSink, removeEdge, removeEdge, removeEdge, removeEdge, removeEdge, removeEdge, removeEdge, removeElementSink, removeNode, removeNode, removeNode, removeNode, removeSink, setAutoCreate, setEdgeFactory, setNodeFactory, setNullAttributesAreErrors, setStrict, stepBegins, stepBegins, write, write
addAttribute, addAttributes, changeAttribute, clearAttributes, clearAttributesWithNoEvent, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, setIndex, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
forEach, spliterator
public static final double GROW_FACTOR
public static final int DEFAULT_NODE_CAPACITY
public static final int DEFAULT_EDGE_CAPACITY
protected HashMap<String,AbstractNode> nodeMap
protected HashMap<String,AbstractEdge> edgeMap
protected AbstractNode[] nodeArray
protected AbstractEdge[] edgeArray
protected int nodeCount
protected int edgeCount
public AdjacencyListGraph(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(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(String id)
id
- Unique identifier of the graph.protected void addEdgeCallback(AbstractEdge edge)
AbstractGraph
addEdgeCallback
in class AbstractGraph
edge
- the edge to be addedprotected void addNodeCallback(AbstractNode node)
AbstractGraph
addNodeCallback
in class AbstractGraph
node
- the node to be addedprotected void removeEdgeCallback(AbstractEdge edge)
AbstractGraph
removeEdgeCallback
in class AbstractGraph
edge
- the edge to be removedprotected void removeNodeCallback(AbstractNode node)
AbstractGraph
removeNodeCallback
in class AbstractGraph
node
- the node to be removedprotected void clearCallback()
AbstractGraph
clearCallback
in class AbstractGraph
public <T extends Edge> T getEdge(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.
getEdge
in interface Graph
getEdge
in class AbstractGraph
id
- Identifier of the edge to find.public <T extends Edge> T 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.
getEdge
in interface Graph
getEdge
in class AbstractGraph
index
- The index of the edge to find.public int getEdgeCount()
Structure
getEdgeCount
in interface Structure
getEdgeCount
in class AbstractGraph
public <T extends Node> T getNode(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.
getNode
in interface Graph
getNode
in class AbstractGraph
id
- Identifier of the node to find.public <T extends Node> T 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.
getNode
in interface Graph
getNode
in class AbstractGraph
index
- Index of the node to find.public int getNodeCount()
Structure
getNodeCount
in interface Structure
getNodeCount
in class AbstractGraph
public <T extends Edge> Iterator<T> getEdgeIterator()
Structure
Iterator<ExtendedEdge> ite = graph.getEdgeIterator();the method will return an Iterator<ExtendedEdge>. If no left part exists, method will just return an Iterator<Edge>.
getEdgeIterator
in interface Structure
getEdgeIterator
in class AbstractGraph
public <T extends Node> Iterator<T> getNodeIterator()
Structure
Iterator<ExtendedNode> ite = graph.getNodeIterator();the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.
getNodeIterator
in interface Structure
getNodeIterator
in class AbstractGraph
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses