org.graphstream.graph.implementations
Class AdjacencyListGraph

java.lang.Object
  extended by org.graphstream.graph.implementations.AbstractElement
      extended by org.graphstream.graph.implementations.AbstractGraph
          extended by org.graphstream.graph.implementations.AdjacencyListGraph
All Implemented Interfaces:
Iterable<Node>, Element, Graph, AttributeSink, ElementSink, Pipe, 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.AttributeChangeEvent
 
Field Summary
static int DEFAULT_EDGE_CAPACITY
           
static int DEFAULT_NODE_CAPACITY
           
static double GROW_FACTOR
           
 
Constructor Summary
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
<T extends Edge>
T
getEdge(int index)
          Get an edge by its index.
<T extends Edge>
T
getEdge(String id)
          Get an edge by its identifier.
 int getEdgeCount()
          Number of edges in this graph.
<T extends Edge>
Iterator<T>
getEdgeIterator()
          Iterator on the set of edges, in an undefined order.
<T extends Node>
T
getNode(int index)
          Get a node by its index.
<T extends Node>
T
getNode(String id)
          Get a node by its identifier.
 int getNodeCount()
          Number of nodes in this graph.
<T extends Node>
Iterator<T>
getNodeIterator()
          Iterator on the set of nodes, in an undefined order.
 
Methods inherited from class org.graphstream.graph.implementations.AbstractGraph
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, 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
 
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graphstream.graph.Element
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
 

Field Detail

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 Detail

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

public AdjacencyListGraph(String id,
                          boolean strictChecking,
                          boolean autoCreate)
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

public AdjacencyListGraph(String id)
Creates an empty graph with strict checking and without auto-creation.

Parameters:
id - Unique identifier of the graph.
Method Detail

getEdge

public <T extends Edge> T getEdge(String id)
Description copied from interface: Graph
Get 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.

Specified by:
getEdge in interface Graph
Specified by:
getEdge in class AbstractGraph
Parameters:
id - Identifier of the edge to find.
Returns:
The searched edge or null if not found.

getEdge

public <T extends Edge> T getEdge(int index)
Description copied from interface: Graph
Get 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.

Specified by:
getEdge in interface Graph
Specified by:
getEdge in class AbstractGraph
Parameters:
index - The index of the edge to find.
Returns:
The edge with the given index

getEdgeCount

public int getEdgeCount()
Description copied from interface: Graph
Number of edges in this graph.

Specified by:
getEdgeCount in interface Graph
Specified by:
getEdgeCount in class AbstractGraph
Returns:
The number of edges.

getNode

public <T extends Node> T getNode(String id)
Description copied from interface: Graph
Get 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.

Specified by:
getNode in interface Graph
Specified by:
getNode in class AbstractGraph
Parameters:
id - Identifier of the node to find.
Returns:
The searched node or null if not found.

getNode

public <T extends Node> T getNode(int index)
Description copied from interface: Graph
Get 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.

Specified by:
getNode in interface Graph
Specified by:
getNode in class AbstractGraph
Parameters:
index - Index of the node to find.
Returns:
The node with the given index

getNodeCount

public int getNodeCount()
Description copied from interface: Graph
Number of nodes in this graph.

Specified by:
getNodeCount in interface Graph
Specified by:
getNodeCount in class AbstractGraph
Returns:
The number of nodes.

getEdgeIterator

public <T extends Edge> Iterator<T> getEdgeIterator()
Description copied from interface: Graph
Iterator on the set of edges, in an undefined order. This method is implicitly generic and returns an Iterator over something which extends Edge. The return type is the one of the left part of the assignment. For example, in the following call :
 Iterator<ExtendedEdge> ite = graph.getEdgeIterator();
 
the method will return an Iterator<ExtendedEdge>. If no left part exists, method will just return an Iterator<Edge>.

Specified by:
getEdgeIterator in interface Graph
Specified by:
getEdgeIterator in class AbstractGraph
Returns:
The iterator.

getNodeIterator

public <T extends Node> Iterator<T> getNodeIterator()
Description copied from interface: Graph
Iterator on the set of nodes, in an undefined order. This method is implicitly generic and returns an Iterator over something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
 Iterator<ExtendedNode> ite = graph.getNodeIterator();
 
the method will return an Iterator<ExtendedNode>. If no left part exists, method will just return an Iterator<Node>.

Specified by:
getNodeIterator in interface Graph
Specified by:
getNodeIterator in class AbstractGraph
Returns:
The iterator.


Copyright © 2011. All Rights Reserved.