|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--drasys.or.graph.Graph | +--drasys.or.graph.BaseGraph | +--drasys.or.graph.SparseGraph
A versatile implementation of a graph that is optimized to store edge sparse graphs.
This graph supports parallel edges and both directed and undirected edges in the same graph.
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
Fields inherited from class drasys.or.graph.Graph |
_symmetric |
Constructor Summary | |
SparseGraph()
|
|
SparseGraph(int vertexCapacity)
|
|
SparseGraph(MatrixI matrix)
Initializes the graph from the values in 'matrix'. |
Method Summary | |
protected void |
_removeVertex(VertexI vertex,
boolean removeZeroVertex)
|
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)
|
void |
removeAllEdges()
Removes all edges from the graph. |
EdgeI |
removeEdge(EdgeI edge,
boolean removeZeroVertices)
Removes the edge from the graph whose keys match the keys in the argument. |
EdgeI |
removeEdge(java.lang.Object fromKey,
java.lang.Object toKey,
java.lang.Object key,
boolean removeZeroVertices)
Removes the edge from the graph whose keys match the arguments. |
VertexI |
removeVertex(java.lang.Object key,
boolean removeZeroVertices)
Removes a vertex whose key matches the argument and all its adjacent edges. |
VertexI |
removeVertex(VertexI vertex,
boolean removeZeroVertices)
Removes a vertex whose key matches the key in the argument and all its adjacent edges. |
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 |
public SparseGraph()
public SparseGraph(int vertexCapacity)
public SparseGraph(MatrixI matrix)
Method Detail |
public boolean isSymmetric()
public void ensureEdgeCapacity(int edgeCapacity)
public EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey) throws DuplicateEdgeException, VertexNotFoundException
public EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object value) throws DuplicateEdgeException, VertexNotFoundException
public EdgeI addEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object value, boolean isDirected) throws DuplicateEdgeException, VertexNotFoundException
public EdgeI addEdge(EdgeI edge) throws DuplicateEdgeException, VertexNotFoundException
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
protected VertexI newVertex(java.lang.Object key, java.lang.Object value)
public EdgeI getMutableEdge(VertexI from, VertexI to, java.lang.Object edgeKey)
public EdgeI getEdge(VertexI from, VertexI to, java.lang.Object edgeKey)
public VertexI removeVertex(VertexI vertex, boolean removeZeroVertices) throws VertexNotFoundException
public VertexI removeVertex(java.lang.Object key, boolean removeZeroVertices) throws VertexNotFoundException
protected void _removeVertex(VertexI vertex, boolean removeZeroVertex)
public EdgeI removeEdge(EdgeI edge, boolean removeZeroVertices) throws VertexNotFoundException, EdgeNotFoundException
public EdgeI removeEdge(java.lang.Object fromKey, java.lang.Object toKey, java.lang.Object key, boolean removeZeroVertices) throws VertexNotFoundException, EdgeNotFoundException
public void removeAllEdges()
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |