gr.demokritos.iit.jinsect.structs
Class EdgeCachedLocator

java.lang.Object
  extended by gr.demokritos.iit.jinsect.structs.EdgeCachedLocator
All Implemented Interfaces:
java.io.Serializable

public class EdgeCachedLocator
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Constructor Summary
EdgeCachedLocator(int iCacheMaxSize)
          Creates a new instance of EdgeCachedLocator, concerning a specific graph.
 
Method Summary
 void addedEdge(salvo.jesus.graph.Edge e)
          Updates cache as needed, if the edges of any vertex already contained within the cache are changed.
 java.util.List getOutgoingEdges(Graph gGraph, salvo.jesus.graph.Vertex vHead)
          Gets the outgoing edges of a given vertex in a directed graph.
protected  java.util.List getOutgoingEdgesUncached(Graph gGraph, salvo.jesus.graph.Vertex vHead)
          Uncached outgoing edge lookup.
 double getSuccessRatio()
          Returns the success ratio of the cache.
 salvo.jesus.graph.Edge locateDirectedEdgeInGraph(Graph gGraph, salvo.jesus.graph.Vertex vHead, salvo.jesus.graph.Vertex vTail)
          Looks up a given directed edge in a selected graph.
 salvo.jesus.graph.Edge locateEdgeInGraph(Graph gGraph, salvo.jesus.graph.Vertex vHead, salvo.jesus.graph.Vertex vTail)
          Looks up a given (undirected) edge in a selected graph.
 salvo.jesus.graph.Vertex locateVertexInGraph(Graph gGraph, salvo.jesus.graph.Vertex vToFind)
          Looks up a vertex in a given graph.
 void resetCache()
          Clears the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeCachedLocator

public EdgeCachedLocator(int iCacheMaxSize)
Creates a new instance of EdgeCachedLocator, concerning a specific graph.

Parameters:
iCacheMaxSize - The maximum number of edges to cache.
Method Detail

locateDirectedEdgeInGraph

public final salvo.jesus.graph.Edge locateDirectedEdgeInGraph(Graph gGraph,
                                                              salvo.jesus.graph.Vertex vHead,
                                                              salvo.jesus.graph.Vertex vTail)
Looks up a given directed edge in a selected graph. The edge is described based on the label of its vertices.

Parameters:
gGraph - The graph to use.
vHead - A vertex with the desired label for the head of the edge.
vTail - A vertex with the desired label for the tail of the edge.
Returns:
The edge, if found, otherwise null.

locateVertexInGraph

public final salvo.jesus.graph.Vertex locateVertexInGraph(Graph gGraph,
                                                          salvo.jesus.graph.Vertex vToFind)
Looks up a vertex in a given graph.

Parameters:
gGraph - The graph to use.
vToFind - The vertex to locate.
Returns:
The vertex, if found, otherwise null.

locateEdgeInGraph

public final salvo.jesus.graph.Edge locateEdgeInGraph(Graph gGraph,
                                                      salvo.jesus.graph.Vertex vHead,
                                                      salvo.jesus.graph.Vertex vTail)
Looks up a given (undirected) edge in a selected graph. The edge is described based on the label of its vertices.

Parameters:
gGraph - The graph to use.
vHead - A vertex with the desired label for the head or tail of the edge.
vTail - A vertex with the desired label for the tail or tail of the edge.
Returns:
The edge, if found, otherwise null.

getOutgoingEdges

public final java.util.List getOutgoingEdges(Graph gGraph,
                                             salvo.jesus.graph.Vertex vHead)
Gets the outgoing edges of a given vertex in a directed graph.

Parameters:
gGraph - The graph to use.
vHead - A vertex with the desired label for the head of the edge.
Returns:
A list of outgoing edges from vHead. If no such edges exist returns an empty list.

resetCache

public void resetCache()
Clears the cache.


addedEdge

public void addedEdge(salvo.jesus.graph.Edge e)
Updates cache as needed, if the edges of any vertex already contained within the cache are changed.

Parameters:
e - The new edge.

getSuccessRatio

public double getSuccessRatio()
Returns the success ratio of the cache.

Returns:
The ratio of hits (number of hits / number of total cache accesses) of the cache.

getOutgoingEdgesUncached

protected java.util.List getOutgoingEdgesUncached(Graph gGraph,
                                                  salvo.jesus.graph.Vertex vHead)
Uncached outgoing edge lookup.

Parameters:
gGraph - The graph to use.
vHead - A vertex with the desired label for the head of the edge.
Returns:
A list of outgoing edges from vHead. If no such edges exist returns an empty list.