gr.demokritos.iit.conceptualIndex.documentModel
Class SymbolicGraph

java.lang.Object
  extended by salvo.jesus.graph.GraphImpl
      extended by salvo.jesus.graph.WeightedGraphImpl
          extended by gr.demokritos.iit.jinsect.structs.UniqueVertexGraph
              extended by gr.demokritos.iit.conceptualIndex.documentModel.SymbolicGraph
All Implemented Interfaces:
Notifier, java.io.Serializable, salvo.jesus.graph.Graph, salvo.jesus.graph.WeightedGraph
Direct Known Subclasses:
CASCGraph

public class SymbolicGraph
extends UniqueVertexGraph
implements Notifier

Represents a graph of symbols of different character lengths. Each symbol is connected to any symbols of smaller size that compose it. Symbols of higher size (also called rank) are considered to be offspring of lower rank symbols that compose the former.

See Also:
Serialized Form

Field Summary
protected  java.util.Set Alphabet
          The alphabet of symbols (characters) contained in the data string
protected  java.lang.String DataString
          The datastring corresponding to the loaded data
 
Fields inherited from class gr.demokritos.iit.jinsect.structs.UniqueVertexGraph
UniqueVertices
 
Fields inherited from class salvo.jesus.graph.GraphImpl
factory, traversal
 
Constructor Summary
SymbolicGraph(int iMinNGramSize, int iMaxNGramSize)
          Creates a new instance of SymbolicGraph given a range of n-gram ranks (lengths).
 
Method Summary
 salvo.jesus.graph.Edge addEdge(salvo.jesus.graph.Vertex vHead, salvo.jesus.graph.Vertex vTail)
          Adds an edge to the graph, if the former does not already exist in the graph.
 java.util.Set getAlphabet()
          Returns the set of characters contained in the data string of the graph.
 salvo.jesus.graph.Vertex getCommonSubnode(java.util.List lNodes)
          Returns a vertex of higher rank (that is to say length), that is composed by at least the vertices appearing in a given list.
 java.lang.String getDataString()
          Returns the data string corresponding to the SymbolicGraph.
 java.util.List getLinkBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo)
          Calculates the link (i.e.
 java.util.List getLinkBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo, java.util.Map mAlreadyVisited)
          Calculates the link (i.e.
 NotificationListener getNotificationListener()
           
 java.util.List getPathBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo)
          Calculates the path between two vertices in this graph.
 java.util.List getPathBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo, java.util.Map mAlreadyVisited)
          Calculates the path between two vertices in this graph, given a list of already visited vertices, that should not be traversed again.
 double getPathLength(java.util.List lPath)
          Calculates the total distance over a graph path, only taking into account edge count.
 double getPathWeight(java.util.List lPath)
          Calculates the total path weight over a graph path.
 java.util.List getShortestLinkBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo)
          Calculates the minimum distance path (i.e.
 java.util.List getShortestLinkBetween(salvo.jesus.graph.Vertex vFrom, salvo.jesus.graph.Vertex vTo, java.util.Map mAlreadyVisited)
          Calculates the shortest link (i.e.
 void loadFromFile(java.lang.String sFilename)
          Augments this graph based on a given file.
static void main(java.lang.String[] sArgs)
          Helper function.
 void removeNotificationListener()
           
 void setDataString(java.lang.String sDataString)
          Augments this graph given a string.
 void setNotificationListener(NotificationListener nlListener)
           
 
Methods inherited from class gr.demokritos.iit.jinsect.structs.UniqueVertexGraph
add, addEdge, contains, locateVertex
 
Methods inherited from class salvo.jesus.graph.WeightedGraphImpl
addEdge, getClosest, minimumSpanningTree, setMinimumSpanningTreeAlgorithm, setShortestPathAlgorithm, shortestPath
 
Methods inherited from class salvo.jesus.graph.GraphImpl
addGraphAddEdgeListener, addGraphAddVertexListener, addGraphRemoveEdgeListener, addGraphRemoveVertexListener, addListener, cloneVertices, containsEdge, containsVertex, forgetConnectedSets, getAdjacentVertices, getAdjacentVertices, getConnectedSet, getConnectedSet, getDegree, getDegree, getEdges, getEdgesCount, getEdgeSet, getGraphFactory, getTraversal, getVertexSet, getVertices, getVerticesCount, getVerticesIterator, isConnected, remove, removeEdge, removeEdges, removeGraphAddEdgeListener, removeGraphAddVertexListener, removeGraphRemoveEdgeListener, removeGraphRemoveVertexListener, removeListener, setGraphFactory, setTraversal, toString, traverse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface salvo.jesus.graph.Graph
addGraphAddEdgeListener, addGraphAddVertexListener, addGraphRemoveEdgeListener, addGraphRemoveVertexListener, addListener, cloneVertices, getAdjacentVertices, getAdjacentVertices, getConnectedSet, getConnectedSet, getDegree, getDegree, getEdges, getEdgesCount, getEdgeSet, getGraphFactory, getTraversal, getVertexSet, getVertices, getVerticesCount, getVerticesIterator, isConnected, remove, removeEdge, removeEdges, removeGraphAddEdgeListener, removeGraphAddVertexListener, removeGraphRemoveEdgeListener, removeGraphRemoveVertexListener, removeListener, setGraphFactory, setTraversal, traverse
 

Field Detail

DataString

protected java.lang.String DataString
The datastring corresponding to the loaded data


Alphabet

protected java.util.Set Alphabet
The alphabet of symbols (characters) contained in the data string

Constructor Detail

SymbolicGraph

public SymbolicGraph(int iMinNGramSize,
                     int iMaxNGramSize)
Creates a new instance of SymbolicGraph given a range of n-gram ranks (lengths).

Parameters:
iMinNGramSize - The minimum n-gram size within this graph.
iMaxNGramSize - The maximum n-gram size within this graph.
Method Detail

getPathBetween

public java.util.List getPathBetween(salvo.jesus.graph.Vertex vFrom,
                                     salvo.jesus.graph.Vertex vTo)
Calculates the path between two vertices in this graph.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getPathBetween

public java.util.List getPathBetween(salvo.jesus.graph.Vertex vFrom,
                                     salvo.jesus.graph.Vertex vTo,
                                     java.util.Map mAlreadyVisited)
Calculates the path between two vertices in this graph, given a list of already visited vertices, that should not be traversed again.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
mAlreadyVisited - A map of already visited vertices, where every visited vertex is mapped to a value of 1.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getShortestLinkBetween

public java.util.List getShortestLinkBetween(salvo.jesus.graph.Vertex vFrom,
                                             salvo.jesus.graph.Vertex vTo)
Calculates the minimum distance path (i.e. undirected path) between two vertices in this graph.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getShortestLinkBetween

public java.util.List getShortestLinkBetween(salvo.jesus.graph.Vertex vFrom,
                                             salvo.jesus.graph.Vertex vTo,
                                             java.util.Map mAlreadyVisited)
Calculates the shortest link (i.e. undirected path between two vertices in this graph, given a list of already visited vertices, that should not be traversed again.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
mAlreadyVisited - A map of already visited vertices, where every visited vertex is mapped to a value of 1.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getLinkBetween

public java.util.List getLinkBetween(salvo.jesus.graph.Vertex vFrom,
                                     salvo.jesus.graph.Vertex vTo)
Calculates the link (i.e. undirected path) between two vertices in this graph.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getLinkBetween

public java.util.List getLinkBetween(salvo.jesus.graph.Vertex vFrom,
                                     salvo.jesus.graph.Vertex vTo,
                                     java.util.Map mAlreadyVisited)
Calculates the link (i.e. undirected path) between two vertices in this graph, given a list of already visited vertices, that should not be traversed again.

Parameters:
vFrom - The starting vertex.
vTo - The destination vertex.
mAlreadyVisited - A map of already visited vertices, where every visited vertex is mapped to a value of 1.
Returns:
A list of edges indicating the path between the starting and destination vertex. If there is no path between the two vertices the returned list will be null.

getPathWeight

public double getPathWeight(java.util.List lPath)
Calculates the total path weight over a graph path.

Parameters:
lPath - The list of edges indicating the path to follow.
Returns:
The total weight of the path, as a sum of individual edge weights.

getPathLength

public final double getPathLength(java.util.List lPath)
Calculates the total distance over a graph path, only taking into account edge count.

Parameters:
lPath - The list of edges indicating the path to follow.
Returns:
The total size of the path, as a sum of individual edge weights.

getCommonSubnode

public salvo.jesus.graph.Vertex getCommonSubnode(java.util.List lNodes)
Returns a vertex of higher rank (that is to say length), that is composed by at least the vertices appearing in a given list.

Parameters:
lNodes - The list of vertices (or nodes) that should be ancestors of the higher rank vertex.
Returns:
The common offspring of the vertices in the given list. If no such offspring vertex is found, then null is returned.

loadFromFile

public void loadFromFile(java.lang.String sFilename)
Augments this graph based on a given file.

Parameters:
sFilename - The filename of the file to load.

setDataString

public void setDataString(java.lang.String sDataString)
Augments this graph given a string. For all n-gram ranks the n-grams are computed and vertices are created mapping lower rank vertices to higher rank vertices.

Parameters:
sDataString - The string used to extract n-grams.

getDataString

public java.lang.String getDataString()
Returns the data string corresponding to the SymbolicGraph.

Returns:
The data string of the graph.

getAlphabet

public java.util.Set getAlphabet()
Returns the set of characters contained in the data string of the graph.

Returns:
A Set containing the unique characters in the data string.

addEdge

public salvo.jesus.graph.Edge addEdge(salvo.jesus.graph.Vertex vHead,
                                      salvo.jesus.graph.Vertex vTail)
                               throws java.lang.Exception
Adds an edge to the graph, if the former does not already exist in the graph. Otherwise, it increases the weight of the edge by one.

Specified by:
addEdge in interface salvo.jesus.graph.Graph
Overrides:
addEdge in class UniqueVertexGraph
Parameters:
vHead - The head vertex of the edge.
vTail - The tail vertex of the edge.
Returns:
The newly added edge
Throws:
java.lang.Exception - If the edge cannot be added.

setNotificationListener

public void setNotificationListener(NotificationListener nlListener)
Specified by:
setNotificationListener in interface Notifier

removeNotificationListener

public void removeNotificationListener()
Specified by:
removeNotificationListener in interface Notifier

getNotificationListener

public NotificationListener getNotificationListener()
Specified by:
getNotificationListener in interface Notifier

main

public static void main(java.lang.String[] sArgs)
Helper function. Checks the functionality of the class.