drasys.or.graph
Class DenseGraph

java.lang.Object
  |
  +--drasys.or.graph.Graph
        |
        +--drasys.or.graph.BaseGraph
              |
              +--drasys.or.graph.DenseGraph

public class DenseGraph
extends BaseGraph
implements AddI

A implementation of a graph that is optimized for dense edges. This graph supports parallel edges and a mixture of directed and undirected edges.
The vertex and edge method 'doubleValue()' returns a double value based on the element's value object. If the value object is not null and either implements 'DoubleI' or is a subclass of 'Number' then the returned value is 'value.doubleValue()'. Otherwise; the value is zero.

References:

Graphs : Theory and Algorithms
    K. Thulasiraman, M.N.S. Swamy / Paperback / Published 1992

See Also:
Serialized Form

Fields inherited from class drasys.or.graph.Graph
_symmetric
 
Constructor Summary
DenseGraph()
           
DenseGraph(int vertexCapacity)
           
 
Method Summary
 EdgeI addEdge(EdgeI edge)
          Adds a new edge to the graph.
 EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey)
          Adds a new edge to the graph where: value=null, isDirected=false, key=null.
 EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object value)
          Adds a new edge to the graph where: isDirected=false, key=null.
 EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object value, boolean isDirected)
          Adds a new edge to the graph where: key=null.
 EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object value, boolean isDirected, java.lang.Object key)
          Adds a new edge to the graph.
 void ensureEdgeCapacity(int edgeCapacity)
          Increases the capacity of the graph if needed to ensure it can efficiently hold this many edges.
 EdgeI getEdge(VertexI from, VertexI to, java.lang.Object edgeKey)
          Get the edge between the from and to vertices whose key matches 'edgeKey'.
 EdgeI getMutableEdge(VertexI from, VertexI to, java.lang.Object edgeKey)
          Get the edge between the from and to vertices whose key matches 'edgeKey'.
 boolean isSymmetric()
          Returns false by default.
protected  VertexI newVertex(java.lang.Object key, java.lang.Object value)
           
 java.lang.String toString()
           
 
Methods inherited from class drasys.or.graph.BaseGraph
addVertex, addVertex, addVertex, ensureVertexCapacity, getChangeCount, getVertex, removeAllVertices, sizeOfDirectedEdges, sizeOfEdges, sizeOfVertices, vertices
 
Methods inherited from class drasys.or.graph.Graph
edges, equals, getEdge, getEdge, isSubsetOf, mutableEdges, setSymmetric, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DenseGraph

public DenseGraph()

DenseGraph

public DenseGraph(int vertexCapacity)
Method Detail

isSymmetric

public boolean isSymmetric()
Returns false by default. If 'setSymmetric' has been called, then the override value is returned.

ensureEdgeCapacity

public void ensureEdgeCapacity(int edgeCapacity)
Increases the capacity of the graph if needed to ensure it can efficiently hold this many edges.

addEdge

public EdgeI addEdge(java.lang.Object fromKey,
                     java.lang.Object toKey)
              throws DuplicateEdgeException,
                     VertexNotFoundException
Adds a new edge to the graph where: value=null, isDirected=false, key=null. Throws 'VertexNotFoundException' if either vertex is not in the graph. Throws 'DuplicateEdgeException' if the edge already exists.

addEdge

public EdgeI addEdge(java.lang.Object fromKey,
                     java.lang.Object toKey,
                     java.lang.Object value)
              throws DuplicateEdgeException,
                     VertexNotFoundException
Adds a new edge to the graph where: isDirected=false, key=null. Throws 'VertexNotFoundException' if either vertex is not in the graph. Throws 'DuplicateEdgeException' if the edge already exists.

addEdge

public EdgeI addEdge(java.lang.Object fromKey,
                     java.lang.Object toKey,
                     java.lang.Object value,
                     boolean isDirected)
              throws DuplicateEdgeException,
                     VertexNotFoundException
Adds a new edge to the graph where: key=null. Throws 'VertexNotFoundException' if either vertex is not in the graph. Throws 'DuplicateEdgeException' if the edge already exists.

addEdge

public EdgeI addEdge(EdgeI edge)
              throws DuplicateEdgeException,
                     VertexNotFoundException
Adds a new edge to the graph.

addEdge

public final EdgeI addEdge(java.lang.Object fromKey,
                           java.lang.Object toKey,
                           java.lang.Object value,
                           boolean isDirected,
                           java.lang.Object key)
                    throws DuplicateEdgeException,
                           VertexNotFoundException
Adds a new edge to the graph. Throws 'VertexNotFoundException' if either vertex is not in the graph. Throws 'DuplicateEdgeException' if the edge already exists.

newVertex

protected VertexI newVertex(java.lang.Object key,
                            java.lang.Object value)
Overrides:
newVertex in class BaseGraph

getMutableEdge

public EdgeI getMutableEdge(VertexI from,
                            VertexI to,
                            java.lang.Object edgeKey)
Get the edge between the from and to vertices whose key matches 'edgeKey'. The graph is allowed to return a mutable edge if that is more efficient, but the edge contents must be used before 'getMutableEdge()' is called again. The arguments 'from' and 'to' must be vertices from this graph. The argument 'edgeKey' is not used.
Returns:
Null if the edge is not in the graph.

getEdge

public EdgeI getEdge(VertexI from,
                     VertexI to,
                     java.lang.Object edgeKey)
Get the edge between the from and to vertices whose key matches 'edgeKey'. The arguments 'from' and 'to' must be vertices from this graph.
Returns:
Null if the edge is not in the graph.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com