Search this API

y.base
Class Graph

java.lang.Object
  extended by y.base.Graph
All Implemented Interfaces:
GraphInterface
Direct Known Subclasses:
LayoutGraph

public class Graph
extends java.lang.Object
implements GraphInterface

This class implements a directed graph structure. Basically, a directed graph consists of a set of objects called "nodes" (represented by instances of class Node) and a set of node pairs which are called "edges" (represented by instances of class Edge).
The directed stems from the fact that all edges in the graph have direction, i.e., they have a distinct source node and a distinct target node. Using the aforementioned pair notation, an edge would be written as (<source node>, <target node>).

Class Graph presents a proper data type that provides support for all essential operations like element creation, removal, access, and iteration.
Important: Class Graph is the single authority for any structural changes to the graph data type. Specifically, this means that there is no way to create or delete a node or an edge without using an actual Graph instance.

Furthermore, this class is also responsible for providing access to its elements. This is done by means of bidirectional cursors that present a read-only view on the node set (interface NodeCursor) and edge set (interface EdgeCursor).

Class Graph fires notification events that signal structural changes, like, e.g., creation, removal, reinsertion, or modification of graph elements.
Classes that implement the GraphListener interface can be registered with this class using the addGraphListener method in order to receive such events.

This class provides direct support for the notion of data accessors. It allows to register so-called data providers (implementations of interface DataProvider) that hold arbitrary data which is associated to its nodes and/or edges.
Also, it serves as a factory to create so-called maps (NodeMap, EdgeMap) that can be utilized to bind arbitrary data to nodes and edges.

See Also:
General Concepts in yFiles, Working With the Graph Structure
 

Field Summary
static int AFTER
          Object insertion specifier.
static int BEFORE
          Object insertion specifier.
 
Constructor Summary
Graph()
          Instantiates an empty Graph object.
Graph(Graph argGraph)
          Instantiates a new Graph object as a copy of the given graph.
Graph(Graph graph, YCursor subNodes)
          Instantiates a new Graph object as a partial copy of the given graph.
 
Method Summary
 void addDataProvider(java.lang.Object providerKey, DataProvider data)
          Registers the given data provider using the given look-up key.
 void addGraphListener(GraphListener listener)
          Registers the given graph listener with this graph.
 void changeEdge(Edge e, Edge e1, Edge e2, int d1, int d2)
          Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
 void changeEdge(Edge e, Node newSource, Edge sourceReference, int sourceD, Node newTarget, Edge targetReference, int targetD)
          Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
 void changeEdge(Edge e, Node newSource, Node newTarget)
          Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
 void clear()
          Removes all nodes and edges from this graph and fires corresponding notification events to inform registered listeners.
 boolean contains(Edge e)
          Whether or not this graph contains the given edge.
 boolean contains(Node v)
          Whether or not this graph contains the given node.
 boolean containsEdge(Node source, Node target)
          Returns whether or not this graph contains an edge that connects the given nodes.
 Graph createCopy()
          Creates a copy of this graph.
 Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2)
          Creates a new edge in this graph to be ordered before or after a given edge and fires a corresponding notification event to inform registered listeners.
 Edge createEdge(Node v, Node w)
          Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners.
 EdgeMap createEdgeMap()
          Returns a newly created edge map that is valid for the edges in this graph.
 Graph createGraph()
          Creates an empty base object of the same type as this graph.
protected  GraphCopier.CopyFactory createGraphCopyFactory()
          Factory method that is called by getGraphCopyFactory() to create a (possibly shared) instance.
 Node createNode()
          Creates a new node in this graph and fires a corresponding notification event to inform registered listeners.
 NodeMap createNodeMap()
          Returns a newly created node map that is valid for the nodes in this graph.
 void disposeEdgeMap(EdgeMap map)
          Informs the graph that the given edge map is no longer needed.
 void disposeNodeMap(NodeMap map)
          Informs the graph that the given node map is no longer needed.
 int E()
          Returns the number of edges in this graph.
 int edgeCount()
          Returns the number of edges in this graph.
 java.util.Iterator edgeObjects()
          Returns an iterator that provides access to all edges residing in this graph.
 EdgeCursor edges()
          Provides access to the edges of the graph.
protected  void fireGraphEvent(GraphEvent e)
          Propagates the given graph event to all registered graph listeners.
 void firePostEvent()
          Propagates a so-called POST event to all registered graph listeners.
 void firePostEvent(java.lang.Object id)
          Like firePostEvent().
 void firePreEvent()
          Propagates a so-called PRE event to all registered graph listeners.
 void firePreEvent(java.lang.Object id)
          Like firePreEvent().
 Edge firstEdge()
          Returns the first edge in this graph.
 Node firstNode()
          Returns the first node in this graph.
protected static Edge firstOutEdge(Node v)
          Low-level iteration support for adjacent edges.
 DataProvider getDataProvider(java.lang.Object providerKey)
          Returns the data provider that is registered with the graph using the given look-up key.
 java.lang.Object[] getDataProviderKeys()
          Returns an array of all data provider look-up keys that are registered with this graph.
 Edge[] getEdgeArray()
          Returns an array containing all edges of this graph.
 GraphCopier.CopyFactory getGraphCopyFactory()
          Returns the copy factory that is associated with this instance.
 java.util.Iterator getGraphListeners()
          Returns an iterator that grants access to all registered graph listeners.
 Node[] getNodeArray()
          Returns an array containing all nodes of this graph.
 EdgeMap[] getRegisteredEdgeMaps()
          Returns all edge maps that have been created by this graph but have not yet been disposed.
 NodeMap[] getRegisteredNodeMaps()
          Returns all node maps that have been created by this graph but have not yet been disposed.
 java.lang.Object getSource(java.lang.Object edge)
          Returns the source node associated with the given edge.
 java.lang.Object getTarget(java.lang.Object edge)
          Returns the target node associated with the given edge.
protected  boolean hasListeners()
          Determines whether there are listeners registered with this instance.
 void hide(Edge e)
          Hides the given edge from this graph.
 void hide(Node v)
          Hides the given node from this graph.
 boolean isEmpty()
          Returns true if this graph contains no nodes.
 Edge lastEdge()
          Returns the last edge in this graph.
 Node lastNode()
          Returns the last node in this graph.
 EdgeList moveSubGraph(NodeList subNodes, Graph targetGraph)
          Moves an induced subgraph to another graph.
 void moveToFirst(Edge e)
          Moves the given edge to the first position within the sequence of edges in this graph.
 void moveToFirst(Node v)
          Moves the given node to the first position within the sequence of nodes in this graph.
 void moveToLast(Edge e)
          Moves the given edge to the last position within the sequence of edges in this graph.
 void moveToLast(Node v)
          Moves the given node to the last position within the sequence of nodes in this graph.
 int N()
          Returns the number of nodes in this graph.
 int nodeCount()
          Returns the number of nodes in this graph.
 java.util.Iterator nodeObjects()
          Returns an iterator that provides access to all nodes residing in this graph.
 NodeCursor nodes()
          Provides access to the nodes of the graph.
 void printNodeSlotSize()
          For internal debugging purposes only.
 void reInsertEdge(Edge e)
          Reinserts a formerly removed edge into this graph and fires a corresponding notification event to inform registered listeners.
 void reInsertNode(Node v)
          Reinserts a formerly removed node into this graph and fires a corresponding notification event to inform registered listeners.
 void removeDataProvider(java.lang.Object providerKey)
          Removes the data provider that is registered using the given look-up key.
 void removeEdge(Edge e)
          Removes the given edge from this graph and fires a corresponding notification event to inform registered listeners.
 void removeGraphListener(GraphListener listener)
          Removes the given graph listener from this graph.
 void removeNode(Node v)
          Removes the given node from this graph.
 void reverseEdge(Edge e)
          Reverses the given edge and fires corresponding notification events to inform registered listeners.
 void setGraphCopyFactory(GraphCopier.CopyFactory copyFactory)
          Sets the copy factory that is associated with this instance.
 void sortEdges(java.util.Comparator comp)
          Sorts the internally held list of edges.
 void sortEdges(java.util.Comparator inComp, java.util.Comparator outComp)
          Sorts incoming and outgoing edges at each node of the graph.
 void sortNodes(java.util.Comparator comp)
          Sorts the internally held list of nodes.
 java.lang.String toString()
          Returns a String representation of this graph.
 void unhide(Edge e)
          Unhides the given edge in this graph.
 void unhide(Node v)
          Unhides the given node in this graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BEFORE

public static final int BEFORE
Object insertion specifier. An object gets inserted before another one.

See Also:
Constant Field Values

AFTER

public static final int AFTER
Object insertion specifier. An object gets inserted after another one.

See Also:
Constant Field Values
Constructor Detail

Graph

public Graph()
Instantiates an empty Graph object.


Graph

public Graph(Graph argGraph)
Instantiates a new Graph object as a copy of the given graph. Values bound to the argument graph via node and edge keys are available in the new Graph instance with the keys registered with argGraph. Only references to these values are copied.

The new Graph instance also inherits all graph listeners registered with the given graph.

This constructor does not use a GraphCopier.

Parameters:
argGraph - The graph to be copied.

Graph

public Graph(Graph graph,
             YCursor subNodes)
Instantiates a new Graph object as a partial copy of the given graph. Only the subgraph induced by the given cursor will be copied to the new Graph instance. Values bound to the argument graph via node and edge keys are available in the new Graph instance with the keys registered with graph. Only references to these values are copied.

The new Graph instance also inherits all graph listeners registered with the given graph.

This constructor does not use a GraphCopier.

Parameters:
graph - The graph to be (partially) copied.
subNodes - A cursor to iterate over the nodes that actually induce the subgraph to be copied.
Method Detail

getGraphCopyFactory

public GraphCopier.CopyFactory getGraphCopyFactory()
Returns the copy factory that is associated with this instance. The factory should be used by software that wants to create copies of this graph instance if it is in need of a factory. The factory instance will be initialized upon first access of this property using method createGraphCopyFactory() (if no instance has been specified before).

Returns:
the factory to use for this instance
See Also:
createGraphCopyFactory(), setGraphCopyFactory(y.util.GraphCopier.CopyFactory)

createGraphCopyFactory

protected GraphCopier.CopyFactory createGraphCopyFactory()
Factory method that is called by getGraphCopyFactory() to create a (possibly shared) instance.

Returns:
the (possibly shared) instance.

setGraphCopyFactory

public void setGraphCopyFactory(GraphCopier.CopyFactory copyFactory)
Sets the copy factory that is associated with this instance. The factory should be used by software that wants to create copies of this graph instance if it is in need of a factory. The factory instance will be initialized upon first access of this property using method createGraphCopyFactory() (if no instance has been specified before).

Parameters:
copyFactory - the new factory to use.
See Also:
createGraphCopyFactory(), setGraphCopyFactory(y.util.GraphCopier.CopyFactory)

hasListeners

protected final boolean hasListeners()
Determines whether there are listeners registered with this instance.


createCopy

public Graph createCopy()
Creates a copy of this graph. Invokes Graph(Graph).

Returns:
The newly created Graph object.

createNode

public Node createNode()
Creates a new node in this graph and fires a corresponding notification event to inform registered listeners.

Returns:
The newly created Node object.

createEdge

public Edge createEdge(Node v,
                       Node w)
Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners. The new edge has source node v and target node w, i.e., would be written as edge e = (v, w).

The edge is appended to the lists of incoming and outgoing edges at the source node and target node, respectively.

Parameters:
v - The source node of the edge.
w - The target node of the edge.
Returns:
The newly created Edge object.

createEdge

public Edge createEdge(Node v,
                       Edge e1,
                       Node w,
                       Edge e2,
                       int d1,
                       int d2)
Creates a new edge in this graph to be ordered before or after a given edge and fires a corresponding notification event to inform registered listeners. The new edge e has source node v and target node w, i.e., would be written as edge e = (v, w).

Edge e is inserted in such a way that an iteration over the edges at node v returns e and an iteration over the edges at w returns e

Precondition:
Edge e1 must have source node v and edge e2 must have target node w.
Parameters:
v - The source node of the edge.
e1 - An edge with source node v.
w - The target node of the edge.
e2 - An edge with target node w.
d1 - One of the object insertion specifiers BEFORE or AFTER.
d2 - One of the object insertion specifiers BEFORE or AFTER.
Returns:
The newly created Edge object.

removeNode

public void removeNode(Node v)
Removes the given node from this graph. All edges connecting to the given node are removed as well (preceding the actual node removal). Corresponding notification events are fired to inform registered listeners.

The node will be deselected before it gets removed.

Parameters:
v - The node to be removed from this graph.

removeEdge

public void removeEdge(Edge e)
Removes the given edge from this graph and fires a corresponding notification event to inform registered listeners.

The edge will be deselected before it gets removed.

Parameters:
e - The edge to be removed.

reInsertNode

public void reInsertNode(Node v)
Reinserts a formerly removed node into this graph and fires a corresponding notification event to inform registered listeners.

The reinserted node is appended to the sequence of nodes in this graph, i.e., normally, its new position does not match the position before its removal.

Parameters:
v - The node to be reinserted.
See Also:
removeNode(Node)

reInsertEdge

public void reInsertEdge(Edge e)
Reinserts a formerly removed edge into this graph and fires a corresponding notification event to inform registered listeners.

The reinserted edge is appended to the sequence of edges in this graph, i.e., normally, its new position does not match the position before its removal. The same holds for the edge's positions in the list of incoming and outgoing edges at its source node and target node, respectively.

Note that reinserting an edge whose source/target is not in the graph (e.g., because it's currently hidden/removed) causes an exception. Hence, in such cases, you first have to unhide/reinsert the corresponding endpoints.

Parameters:
e - The edge to be reinserted.
See Also:
removeEdge(Edge)

changeEdge

public void changeEdge(Edge e,
                       Edge e1,
                       Edge e2,
                       int d1,
                       int d2)
Redefines an edge's end points and fires corresponding notification events to inform registered listeners. Edge e has source node v := e1.source() and target node w := e2.target().

Edge e is inserted in such a way that an iteration over the edges at v returns e and an iteration over the edges at w returns e

Precondition:
Edges e, e1, and e2 must belong to this graph.
Parameters:
e - The edge to be changed.
e1 - Reference edge for insertion at a new source node.
e2 - Reference edge for insertion at a new target node.
d1 - One of the object insertion specifiers BEFORE or AFTER.
d2 - One of the object insertion specifiers BEFORE or AFTER.

changeEdge

public void changeEdge(Edge e,
                       Node newSource,
                       Edge sourceReference,
                       int sourceD,
                       Node newTarget,
                       Edge targetReference,
                       int targetD)
Redefines an edge's end points and fires corresponding notification events to inform registered listeners. Edge e has source node v := sourceReference.source() or v := newSource, if sourceReference == null and target node w := targetReference.target() or w := newTarget, if targetReference == null.

Edge e is inserted in such a way that an iteration over the edges at v returns e and an iteration over the edges at w returns e

Precondition:
Edge e must belong to this graph. Also, either sourceReference or newSource must be non-null and belong to this graph, and either targetReference or newTarget must be non-null and belong to this graph.
Parameters:
e - The edge to be changed.
newSource - The new source node.
sourceReference - Reference edge for insertion at the new source node.
sourceD - One of the object insertion specifiers BEFORE or AFTER.
newTarget - The new target node.
targetReference - Reference edge for insertion at the new target node.
targetD - One of the object insertion specifiers BEFORE or AFTER.

changeEdge

public void changeEdge(Edge e,
                       Node newSource,
                       Node newTarget)
Redefines an edge's end points and fires corresponding notification events to inform registered listeners.

The edge is appended to the lists of incoming and outgoing edges at the given source node and target node, respectively.

Precondition:
newSource and newTarget must belong to this graph.
Parameters:
e - The edge to be changed.
newSource - The new source node of the given edge.
newTarget - The new target node of the given edge.

reverseEdge

public void reverseEdge(Edge e)
Reverses the given edge and fires corresponding notification events to inform registered listeners. This operation exchanges source and target node of the edge.


hide

public void hide(Edge e)
Hides the given edge from this graph. Hiding an edge means to (temporarily) remove the edge from the graph.

The only difference to a proper edge removal as performed by removeEdge(Edge) is that no GraphEvent will be emitted that signals the structural change (i.e. the edge's removal).

Generally, hiding should only be used in the sense of temporarily removing an object that will be reinserted shortly after.

To reinsert a hidden edge use unhide(Edge).

See Also:
hide(Node), unhide(Node)

unhide

public void unhide(Edge e)
Unhides the given edge in this graph. Unhiding an edge means to reinsert an edge that was formerly hidden from this graph by a call to hide(Edge).

The only difference to a proper edge reinsertion as performed by reInsertEdge(Edge) is that no GraphEvent will be emitted that signals the structural change (i.e. the edge's reinsertion).

Note that unhiding an edge whose source/target is not in the graph (e.g., because it's currently hidden/removed) causes an exception. Hence, in such cases, you first have to unhide/reinsert the corresponding endpoints.

See Also:
hide(Node), unhide(Node)

hide

public void hide(Node v)
Hides the given node from this graph. Hiding a node means to (temporarily) remove the node from the graph.

The only difference to a proper node removal as performed by removeNode(Node) is that no GraphEvent will be emitted that signals the structural change (i.e. the node's removal).

Generally, hiding should only be used in the sense of temporarily removing an object that will be reinserted shortly after.

To reinsert a hidden node use unhide(Node).

See Also:
hide(Edge), unhide(Edge)

unhide

public void unhide(Node v)
Unhides the given node in this graph. Unhiding a node means to reinsert a node that was formerly hidden from this graph by a call to hide(Node).

The only difference to a proper node reinsertion as performed by reInsertNode(Node) is that no GraphEvent will be emitted that signals the structural change (i.e. the node's reinsertion).


moveToLast

public void moveToLast(Node v)
Moves the given node to the last position within the sequence of nodes in this graph.


moveToFirst

public void moveToFirst(Node v)
Moves the given node to the first position within the sequence of nodes in this graph.


moveToLast

public void moveToLast(Edge e)
Moves the given edge to the last position within the sequence of edges in this graph.


moveToFirst

public void moveToFirst(Edge e)
Moves the given edge to the first position within the sequence of edges in this graph.


N

public int N()
Returns the number of nodes in this graph. Same as nodeCount().

Returns:
the number of nodes in this graph.

nodeCount

public int nodeCount()
Returns the number of nodes in this graph.

Returns:
the number of nodes in this graph.

E

public int E()
Returns the number of edges in this graph. Same as edgeCount().

Returns:
the number of edges in this graph.

edgeCount

public int edgeCount()
Returns the number of edges in this graph.

Returns:
the number of edges in this graph.

isEmpty

public boolean isEmpty()
Returns true if this graph contains no nodes.

Returns:
true if this graph contains no nodes, otherwise false.

clear

public void clear()
Removes all nodes and edges from this graph and fires corresponding notification events to inform registered listeners.


contains

public boolean contains(Node v)
Whether or not this graph contains the given node.


contains

public boolean contains(Edge e)
Whether or not this graph contains the given edge.


containsEdge

public boolean containsEdge(Node source,
                            Node target)
Returns whether or not this graph contains an edge that connects the given nodes.

Parameters:
source - The source node.
target - The target node.
See Also:
Node.getEdgeTo(Node), Node.getEdgeFrom(Node), Node.getEdge(Node)

firstNode

public Node firstNode()
Returns the first node in this graph.

Precondition:
!isEmpty()

firstEdge

public Edge firstEdge()
Returns the first edge in this graph.

Precondition:
edgeCount() > 0

lastNode

public Node lastNode()
Returns the last node in this graph.

Precondition:
!isEmpty()

lastEdge

public Edge lastEdge()
Returns the last edge in this graph.

Precondition:
edgeCount() > 0

getNodeArray

public Node[] getNodeArray()
Returns an array containing all nodes of this graph.


getEdgeArray

public Edge[] getEdgeArray()
Returns an array containing all edges of this graph.


nodes

public NodeCursor nodes()
Provides access to the nodes of the graph.

Returns:
A NodeCursor to iterate over the nodes in the graph.

edges

public EdgeCursor edges()
Provides access to the edges of the graph.

Returns:
An EdgeCursor to iterate over the edges in the graph.

moveSubGraph

public EdgeList moveSubGraph(NodeList subNodes,
                             Graph targetGraph)
Moves an induced subgraph to another graph.

Precondition:
The nodes in subNodes must belong to this graph.
Parameters:
subNodes - A list of nodes that induce the subgraph to be moved.
targetGraph - The graph where the subgraph is moved to.
Returns:
A list of removed edges that connected the induced subgraph to this graph.

createGraph

public Graph createGraph()
Creates an empty base object of the same type as this graph.

Subclasses should override this method.


sortEdges

public void sortEdges(java.util.Comparator comp)
Sorts the internally held list of edges. If the given comparator is null, then the edges will not be sorted. This list determines the order of the edges as returned by edges().

Parameters:
comp - The comparator used for the edges.

sortNodes

public void sortNodes(java.util.Comparator comp)
Sorts the internally held list of nodes. If the given comparator is null, then the nodes will not be sorted. This list determines the order of the nodes as returned by nodes().

Parameters:
comp - The comparator used for the nodes.

sortEdges

public void sortEdges(java.util.Comparator inComp,
                      java.util.Comparator outComp)
Sorts incoming and outgoing edges at each node of the graph. If a given comparator is null, then the corresponding edges (i.e., incoming/outgoing) will not be sorted. This sorts the order of the edges as returned by Node.outEdges() and Node.inEdges() respectively.

Parameters:
inComp - The comparator used for the incoming edges at each node.
outComp - The comparator used for the outgoing edges at each node.

addGraphListener

public void addGraphListener(GraphListener listener)
Registers the given graph listener with this graph. The listener will receive graph events that signal structural changes occurring within this graph.

See Also:
GraphEvent

removeGraphListener

public void removeGraphListener(GraphListener listener)
Removes the given graph listener from this graph.


getGraphListeners

public java.util.Iterator getGraphListeners()
Returns an iterator that grants access to all registered graph listeners.


firePreEvent

public void firePreEvent()
Propagates a so-called PRE event to all registered graph listeners. This method should only be used if a corresponding call to firePostEvent() follows.

Generally, PRE and POST events serve as a means to bracket a sequence of graph events.

See Also:
GraphListener

firePreEvent

public void firePreEvent(java.lang.Object id)
Like firePreEvent(). Additionally, an event ID may be specified.

Parameters:
id - An identifying tag for the event.
See Also:
GraphListener

firePostEvent

public void firePostEvent()
Propagates a so-called POST event to all registered graph listeners. This method should only be used if a corresponding call to firePreEvent() was made.

Generally, PRE and POST events serve as a means to bracket a sequence of graph events.

See Also:
GraphListener

firePostEvent

public void firePostEvent(java.lang.Object id)
Like firePostEvent(). Additionally, an event ID may be specified.

Parameters:
id - An identifying tag for the event.
See Also:
GraphListener

fireGraphEvent

protected void fireGraphEvent(GraphEvent e)
Propagates the given graph event to all registered graph listeners.


createNodeMap

public NodeMap createNodeMap()
Returns a newly created node map that is valid for the nodes in this graph. The implementation returned by this method can be used for any node that is part of this Graph instance at any point of time, i.e., it is safe to modify the graph structure (add and remove nodes and edges) freely.

The implementation returned uses O(n) memory at all times and provides true O(1) read and write access for each node.

In order to release the resources held by this map, disposeNodeMap(NodeMap) has to be called.


createEdgeMap

public EdgeMap createEdgeMap()
Returns a newly created edge map that is valid for the edges in this graph. The implementation returned by this method can be used for any edge that is part of this Graph instance at any point of time, i.e., it is safe to modify the graph structure (add and remove nodes and edges) freely.

The implementation returned uses O(m) memory at all times and provides true O(1) read and write access for each edge.

In order to release the resources held by this map, disposeEdgeMap(EdgeMap) has to be called.


disposeNodeMap

public void disposeNodeMap(NodeMap map)
Informs the graph that the given node map is no longer needed. This method is used for NodeMap implementations that have been obtained using the createNodeMap() factory method.

Calling this method will destroy the node map and associated resources can be freed. It is strongly recommended to dispose of all node maps that are not needed anymore using this method.


disposeEdgeMap

public void disposeEdgeMap(EdgeMap map)
Informs the graph that the given edge map is no longer needed. This method is used for EdgeMap implementations that have been obtained using the createEdgeMap() factory method.

Calling this method will destroy the edge map and associated resources can be freed. It is strongly recommended to dispose of all edge maps that are not needed anymore using this method.


getRegisteredNodeMaps

public NodeMap[] getRegisteredNodeMaps()
Returns all node maps that have been created by this graph but have not yet been disposed.

See Also:
createNodeMap(), disposeNodeMap(NodeMap)

getRegisteredEdgeMaps

public EdgeMap[] getRegisteredEdgeMaps()
Returns all edge maps that have been created by this graph but have not yet been disposed.

See Also:
createEdgeMap(), disposeEdgeMap(EdgeMap)

getSource

public java.lang.Object getSource(java.lang.Object edge)
Returns the source node associated with the given edge.

Specified by:
getSource in interface GraphInterface

getTarget

public java.lang.Object getTarget(java.lang.Object edge)
Returns the target node associated with the given edge.

Specified by:
getTarget in interface GraphInterface

nodeObjects

public java.util.Iterator nodeObjects()
Returns an iterator that provides access to all nodes residing in this graph.

Specified by:
nodeObjects in interface GraphInterface

edgeObjects

public java.util.Iterator edgeObjects()
Returns an iterator that provides access to all edges residing in this graph.

Specified by:
edgeObjects in interface GraphInterface

getDataProvider

public DataProvider getDataProvider(java.lang.Object providerKey)
Returns the data provider that is registered with the graph using the given look-up key. The look-up domain of a returned data provider normally consists of either the nodes of the graph, or its edges, or both.

Specified by:
getDataProvider in interface GraphInterface

addDataProvider

public void addDataProvider(java.lang.Object providerKey,
                            DataProvider data)
Registers the given data provider using the given look-up key. If there is already a data provider registered with that key, then it will be overwritten with the new one.


removeDataProvider

public void removeDataProvider(java.lang.Object providerKey)
Removes the data provider that is registered using the given look-up key.


getDataProviderKeys

public java.lang.Object[] getDataProviderKeys()
Returns an array of all data provider look-up keys that are registered with this graph.

Specified by:
getDataProviderKeys in interface GraphInterface

firstOutEdge

protected static final Edge firstOutEdge(Node v)
Low-level iteration support for adjacent edges.


printNodeSlotSize

public void printNodeSlotSize()
For internal debugging purposes only.


toString

public java.lang.String toString()
Returns a String representation of this graph. The result contains the String representations of all nodes followed by the String representations of all edges.

Overrides:
toString in class java.lang.Object

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.