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(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 |
---|---|
<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.
|
addAttributeSink, addEdge, addEdge, addEdge, addEdge, addEdge, addEdge, addElementSink, addNode, addSink, 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, removeElementSink, removeNode, removeNode, removeNode, removeSink, setAutoCreate, setEdgeFactory, setNodeFactory, setNullAttributesAreErrors, setStrict, stepBegins, stepBegins, write, write
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, toString
equals, 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
public static final double GROW_FACTOR
public static final int DEFAULT_NODE_CAPACITY
public static final int DEFAULT_EDGE_CAPACITY
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.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
Copyright © 2015. All rights reserved.