- java.lang.Object
-
- org.jruby.dirgra.DirectedGraph<T>
-
public class DirectedGraph<T extends ExplicitVertexID> extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private int
edgeLength
private Edge<T>[]
edges
private static int
INITIAL_SIZE
private java.util.ArrayList
inOrderVerticeData
(package private) int
vertexIDCounter
private java.util.Map<T,Vertex<T>>
vertices
-
Constructor Summary
Constructors Constructor Description DirectedGraph()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Edge<T>
addEdge(Edge<T> newEdge)
void
addEdge(T source, T destination, java.lang.Object type)
java.util.Collection<T>
allData()
java.util.Collection<Edge<T>>
edges()
java.lang.Iterable<Edge<T>>
edgesOfType(java.lang.Object type)
Vertex<T>
findOrCreateVertexFor(T data)
Find existing vertex and if it is not present create it.Vertex<T>
findVertexFor(T data)
protected Edge<T>[]
getEdges()
java.util.Collection<T>
getInorderData()
protected Edge<T>[]
growEdges(Edge<T>[] array, int realLength)
void
removeEdge(Edge<T> edge)
void
removeEdge(T source, T destination)
void
removeVertexFor(T data)
int
size()
java.lang.String
toString()
java.util.Collection<Vertex<T>>
vertices()
-
-
-
Field Detail
-
INITIAL_SIZE
private static int INITIAL_SIZE
-
vertices
private java.util.Map<T extends ExplicitVertexID,Vertex<T extends ExplicitVertexID>> vertices
-
edges
private Edge<T extends ExplicitVertexID>[] edges
-
edgeLength
private int edgeLength
-
inOrderVerticeData
private java.util.ArrayList inOrderVerticeData
-
vertexIDCounter
int vertexIDCounter
-
-
Method Detail
-
allData
public java.util.Collection<T> allData()
-
getInorderData
public java.util.Collection<T> getInorderData()
- Returns:
- data in the order it was added to this graph.
-
findOrCreateVertexFor
public Vertex<T> findOrCreateVertexFor(T data)
Find existing vertex and if it is not present create it.- Parameters:
data
- to find a vertex for- Returns:
- vertex for given data. If vertex is not present it creates vertex and returns it.
-
removeVertexFor
public void removeVertexFor(T data)
-
size
public int size()
- Returns:
- the number of vertices in the graph.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-