Class AdjacencyListGraph
java.lang.Object
org.graphstream.graph.implementations.AbstractElement
org.graphstream.graph.implementations.AbstractGraph
org.graphstream.graph.implementations.AdjacencyListGraph
- All Implemented Interfaces:
Iterable<Node>,Element,Graph,Structure,AttributeSink,ElementSink,Pipe,Replayable,Sink,Source
- Direct Known Subclasses:
MultiGraph,SingleGraph
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
AbstractElement.AttributeChangeEventNested classes/interfaces inherited from interface org.graphstream.stream.Replayable
Replayable.Controller -
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_EDGE_CAPACITYstatic intDEFAULT_NODE_CAPACITYstatic doubleGROW_FACTOR -
Constructor Summary
Constructors Constructor 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. -
Method Summary
Modifier and Type Method Description Stream<Edge>edges()EdgegetEdge(int index)Get an edge by its index.EdgegetEdge(String id)Get an edge by its identifier.intgetEdgeCount()Number of edges in this graph.NodegetNode(int index)Get a node by its index.NodegetNode(String id)Get a node by its identifier.intgetNodeCount()Number of nodes in this graph.Stream<Node>nodes()Methods inherited from class org.graphstream.graph.implementations.AbstractGraph
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, stepBeginsMethods inherited from class org.graphstream.graph.implementations.AbstractElement
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, setAttribute, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.graphstream.graph.Element
attributeKeys, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, getLabel, getMap, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasLabel, hasMap, hasNumber, hasVector, removeAttribute, setAttribute, setAttributesMethods inherited from interface org.graphstream.graph.Graph
addEdge, addEdge, addEdge, addEdge, addEdge, read, read, removeEdge, removeEdge, removeEdge, removeEdge, removeNode, removeNode, write, write
-
Field Details
-
GROW_FACTOR
public static final double GROW_FACTOR- See Also:
- Constant Field Values
-
DEFAULT_NODE_CAPACITY
public static final int DEFAULT_NODE_CAPACITY- See Also:
- Constant Field Values
-
DEFAULT_EDGE_CAPACITY
public static final int DEFAULT_EDGE_CAPACITY- See Also:
- Constant Field Values
-
-
Constructor Details
-
AdjacencyListGraph
public AdjacencyListGraph(String id, boolean strictChecking, boolean autoCreate, int initialNodeCapacity, int initialEdgeCapacity)Creates an empty graph.- Parameters:
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.
-
AdjacencyListGraph
Creates an empty graph with default edge and node capacity.- Parameters:
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.
-
AdjacencyListGraph
Creates an empty graph with strict checking and without auto-creation.- Parameters:
id- Unique identifier of the graph.
-
-
Method Details
-
nodes
-
edges
-
getEdge
Description copied from interface:GraphGet an edge by its identifier. This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :ExtendedEdge edge = graph.getEdge("...");the method will return an ExtendedEdge edge. If no left part exists, method will just return an Edge.
- Parameters:
id- Identifier of the edge to find.- Returns:
- The searched edge or null if not found.
-
getEdge
Description copied from interface:GraphGet an edge by its index. This method is implicitly generic and returns something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :ExtendedEdge edge = graph.getEdge(index);
the method will return an ExtendedEdge edge. If no left part exists, method will just return an Edge.
- Parameters:
index- The index of the edge to find.- Returns:
- The edge with the given index
-
getEdgeCount
public int getEdgeCount()Description copied from interface:StructureNumber of edges in this graph.- Returns:
- The number of edges.
-
getNode
Description copied from interface:GraphGet a node by its identifier. This method is implicitly generic and returns something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :ExtendedNode node = graph.getNode("...");the method will return an ExtendedNode node. If no left part exists, method will just return a Node.
- Parameters:
id- Identifier of the node to find.- Returns:
- The searched node or null if not found.
-
getNode
Description copied from interface:GraphGet a node by its index. This method is implicitly generic and returns something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :ExtendedNode node = graph.getNode(index);
the method will return an ExtendedNode node. If no left part exists, method will just return a Node.
- Parameters:
index- Index of the node to find.- Returns:
- The node with the given index
-
getNodeCount
public int getNodeCount()Description copied from interface:StructureNumber of nodes in this graph.- Returns:
- The number of nodes.
-