scratch.joshua.jung_2_0.core
Class SimpleDirectedSparseGraph<V,E extends DirectedEdge>

java.lang.Object
  extended by scratch.joshua.jung_2_0.core.SimpleAbstractSparseGraph<V,E>
      extended by scratch.joshua.jung_2_0.core.SimpleDirectedSparseGraph<V,E>
All Implemented Interfaces:
ArchetypeGraph<V,E>, DirectedGraph<V,E>, Graph<V,E>

public class SimpleDirectedSparseGraph<V,E extends DirectedEdge>
extends SimpleAbstractSparseGraph<V,E>
implements DirectedGraph<V,E>


Field Summary
protected  Map<E,Pair<V>> edges
           
protected  Map<V,Pair<Set<E>>> vertices
           
 
Constructor Summary
SimpleDirectedSparseGraph()
           
 
Method Summary
 boolean addDirectedEdge(E edge, V source, V dest)
          Adds edge to the graph.
 boolean addVertex(V vertex)
           
 E findEdge(V v1, V v2)
           
 V getDest(E edge)
           
 Collection getEdges()
           
 Pair<V> getEndpoints(E edge)
           
 Collection getIncidentEdges(V vertex)
           
 Collection<E> getInEdges(V vertex)
           
 Collection getNeighbors(V vertex)
           
 Collection<E> getOutEdges(V vertex)
           
 Collection<V> getPredecessors(V vertex)
           
 V getSource(E edge)
           
 Collection<V> getSuccessors(V vertex)
           
 Collection getVertices()
           
 boolean isDest(V vertex, E edge)
           
 boolean isSource(V vertex, E edge)
           
 boolean removeEdge(E edge)
           
 boolean removeVertex(V vertex)
           
 
Methods inherited from class scratch.joshua.jung_2_0.core.SimpleAbstractSparseGraph
areIncident, areNeighbors, degree, getIncidentVertices, getOpposite, inDegree, isPredecessor, isSuccessor, numNeighbors, numPredecessors, numSuccessors, outDegree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface scratch.joshua.jung_2_0.core.Graph
getOpposite, inDegree, isPredecessor, isSuccessor, numPredecessors, numSuccessors, outDegree
 
Methods inherited from interface scratch.joshua.jung_2_0.core.ArchetypeGraph
areIncident, areNeighbors, degree, getIncidentVertices, numNeighbors
 

Field Detail

vertices

protected Map<V,Pair<Set<E extends DirectedEdge>>> vertices

edges

protected Map<E extends DirectedEdge,Pair<V>> edges
Constructor Detail

SimpleDirectedSparseGraph

public SimpleDirectedSparseGraph()
Method Detail

getEdges

public Collection getEdges()
Specified by:
getEdges in interface ArchetypeGraph<V,E extends DirectedEdge>

getVertices

public Collection getVertices()
Specified by:
getVertices in interface ArchetypeGraph<V,E extends DirectedEdge>

addVertex

public boolean addVertex(V vertex)
Specified by:
addVertex in interface ArchetypeGraph<V,E extends DirectedEdge>

removeVertex

public boolean removeVertex(V vertex)
Specified by:
removeVertex in interface ArchetypeGraph<V,E extends DirectedEdge>

removeEdge

public boolean removeEdge(E edge)
Specified by:
removeEdge in interface ArchetypeGraph<V,E extends DirectedEdge>

getInEdges

public Collection<E> getInEdges(V vertex)
Specified by:
getInEdges in interface Graph<V,E extends DirectedEdge>

getOutEdges

public Collection<E> getOutEdges(V vertex)
Specified by:
getOutEdges in interface Graph<V,E extends DirectedEdge>

getPredecessors

public Collection<V> getPredecessors(V vertex)
Specified by:
getPredecessors in interface Graph<V,E extends DirectedEdge>

getSuccessors

public Collection<V> getSuccessors(V vertex)
Specified by:
getSuccessors in interface Graph<V,E extends DirectedEdge>

getNeighbors

public Collection getNeighbors(V vertex)
Specified by:
getNeighbors in interface ArchetypeGraph<V,E extends DirectedEdge>

getIncidentEdges

public Collection getIncidentEdges(V vertex)
Specified by:
getIncidentEdges in interface ArchetypeGraph<V,E extends DirectedEdge>

findEdge

public E findEdge(V v1,
                  V v2)
Specified by:
findEdge in interface ArchetypeGraph<V,E extends DirectedEdge>

addDirectedEdge

public boolean addDirectedEdge(E edge,
                               V source,
                               V dest)
Adds edge to the graph. Also adds source and dest to the graph if they are not already present. Returns false if the specified edge is

Specified by:
addDirectedEdge in interface DirectedGraph<V,E extends DirectedEdge>

getSource

public V getSource(E edge)
Specified by:
getSource in interface DirectedGraph<V,E extends DirectedEdge>

getDest

public V getDest(E edge)
Specified by:
getDest in interface DirectedGraph<V,E extends DirectedEdge>

isSource

public boolean isSource(V vertex,
                        E edge)
Specified by:
isSource in interface DirectedGraph<V,E extends DirectedEdge>

isDest

public boolean isDest(V vertex,
                      E edge)
Specified by:
isDest in interface DirectedGraph<V,E extends DirectedEdge>

getEndpoints

public Pair<V> getEndpoints(E edge)
Specified by:
getEndpoints in interface Graph<V,E extends DirectedEdge>