Top Fields Constructors Methods
org.jruby.dirgra

public Class DirectedGraph<T extends ExplicitVertexID, U>

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collection, .Collections, .HashMap, .Map

Field Summary

Modifier and TypeField and Description
private int
private Edge<T, U>[]
private static final int
private ArrayList<E>
pack-priv int
private final Map<T, Vertex<T, U>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Edge<T, U>
addEdge(Edge<T, U> newEdge)

public void
addEdge(T source, T destination, U type)

public Collection<T>
public Collection<Edge<T, U>>
public Iterable<Edge<T, U>>
edgesOfType(U type)

public Vertex<T, U>

Returns:

vertex for given data. If vertex is not present it creates vertex and returns it.
findOrCreateVertexFor
(T
to find a vertex for
data
)

Find existing vertex and if it is not present create it.

public Vertex<T, U>
findVertexFor(T data)

protected Edge<T, U>[]
public Collection<T>

Returns:

data in the order it was added to this graph.
getInorderData
()

protected Edge<T, U>[]
growEdges(Edge<T, U>[] array, int realLength)

public void
removeEdge(Edge<T, U> edge)

public void
removeEdge(T source, T destination)

public void
public int

Returns:

the number of vertices in the graph.
size
()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<Vertex<T, U>>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

edgeLengthback to summary
private int edgeLength
edgesback to summary
private Edge<T, U>[] edges
INITIAL_SIZEback to summary
private static final int INITIAL_SIZE
inOrderVerticeDataback to summary
private ArrayList<E> inOrderVerticeData
vertexIDCounterback to summary
pack-priv int vertexIDCounter
verticesback to summary
private final Map<T, Vertex<T, U>> vertices

Constructor Detail

DirectedGraphback to summary
public DirectedGraph()

Method Detail

addEdgeback to summary
protected Edge<T, U> addEdge(Edge<T, U> newEdge)
addEdgeback to summary
public void addEdge(T source, T destination, U type)
allDataback to summary
public Collection<T> allData()
edgesback to summary
public Collection<Edge<T, U>> edges()
edgesOfTypeback to summary
public Iterable<Edge<T, U>> edgesOfType(U type)
findOrCreateVertexForback to summary
public Vertex<T, U> findOrCreateVertexFor(T data)

Find existing vertex and if it is not present create it.

Parameters
data:T

to find a vertex for

Returns:Vertex<T, U>

vertex for given data. If vertex is not present it creates vertex and returns it.

findVertexForback to summary
public Vertex<T, U> findVertexFor(T data)
getEdgesback to summary
protected Edge<T, U>[] getEdges()
getInorderDataback to summary
public Collection<T> getInorderData()
Returns:Collection<T>

data in the order it was added to this graph.

growEdgesback to summary
protected Edge<T, U>[] growEdges(Edge<T, U>[] array, int realLength)
removeEdgeback to summary
public void removeEdge(Edge<T, U> edge)
removeEdgeback to summary
public void removeEdge(T source, T destination)
removeVertexForback to summary
public void removeVertexFor(T data)
sizeback to summary
public int size()
Returns:int

the number of vertices in the graph.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
verticesback to summary
public Collection<Vertex<T, U>> vertices()