public class IOGraph<V extends Comparable,E> extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Constructor and Description |
---|
IOGraph() |
IOGraph(SoftwareServerClient icr)
Class constructor.
|
IOGraph(String url)
Class constructor (loads data from a CSR database via a web script to bypass database access restrictions).
|
IOGraph(String server,
String user,
String password)
Class constructor (loads data from a CSR database).
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(V source,
V target,
E edge)
Add an edge to the graph.
|
void |
addEdge(V source,
V target,
E edge,
Double w)
Add an edge to the graph.
|
void |
addEdgeOnce(V source,
V target,
E edge)
Add an edge to the graph only if it doesn't exist.
|
void |
addGraph(IOGraph<V,E> iograph)
Merge another I/O-graph into this one.
|
int |
addVertex(V vertex)
Add a vertex to the graph if not already present.
|
kgm.utility.Pair<Vector<Integer>,Vector<Double>> |
bellmanFord(int source)
Bellman Ford shortest path.
|
void |
clear()
Clear the graph.
|
void |
complexity() |
kgm.utility.Pair<Vector<Integer>,Vector<Double>> |
dijkstra(int source)
Dijstra shortest path.
|
Vector<Vector<Boolean>> |
getActiveEdges()
Get the list indicating which edges are currently active.
|
Vector<Boolean> |
getActiveVertices()
Determine and return which vertices are being used by the currently active edges.
|
Vector<Vector<Integer>> |
getAdjacencyList()
Get the adjacency list representing graph edges.
|
PolyglotAuxiliary.Conversion<V,E> |
getConversion(String edge_string,
String input_string,
String output_string)
Get the conversion possessing the given name, input, and output
|
Vector<PolyglotAuxiliary.Conversion<V,E>> |
getConversions(String conversions_string)
Parse a string containing conversion information
|
TreeSet<Integer> |
getDomain(int target)
Get the set of all vertices that can reach the target vertex.
|
TreeSet<String> |
getDomainStrings()
Get a set of all vertices that can reach other vertices.
|
TreeSet<String> |
getDomainStrings(String target)
Get a set of all vertices that can reach the target vertex.
|
Vector<Vector<E>> |
getEdges()
Get the graph edges.
|
Vector<Vector<String>> |
getEdgeStrings()
Get the string representations for the edges.
|
double |
getEdgeWeight(V input,
V output,
E edge)
Return the weight associated with this conversion.
|
IOGraph<String,String> |
getIOGraphStrings()
Get a string only version of this IOGraph.
|
Double |
getMaxEdgeWeight(int v0,
int v1)
Get the maximum weight among parallel edges between the vertices specified.
|
Vector<Double> |
getMaxPathWeights(Vector<Integer> path)
Get the maximum weights along the path specified.
|
double |
getMinimumWeight()
Returns the minimum weight a path can be to be considered.
|
Vector<E> |
getParallelEdges(V source,
V target,
E edge)
Get a list of edges parallel to the given edge.
|
static Vector<Integer> |
getPath(Vector<Integer> paths,
int source,
int target)
Follow a path back from target to source given the single source shortest paths from the source.
|
String |
getPathString(Vector<Integer> path)
Convert a path into a string representation.
|
TreeSet<Integer> |
getRange(int index)
Return a set of all reachable vertices from the given source.
|
TreeSet<Integer> |
getRangeIntersection(TreeSet<Integer> set)
Get the range intersection of the vertices in the given set.
|
TreeSet<String> |
getRangeIntersectionStrings(TreeSet<String> set)
Get the range intersection of the vertices in the given set.
|
TreeSet<String> |
getRangeStrings()
Returns a set of vertex strings that are reachable from other vertices.
|
TreeSet<String> |
getRangeStrings(String string)
Returns a set of vertex strings that are reachable from a given source vertex.
|
Vector<PolyglotAuxiliary.Conversion<V,E>> |
getShortestConversionPath(String source_string,
String target_string,
boolean ENABLE_WEIGHTED_PATHS)
Get the shortest list of the conversion tasks required to convert from a given input to a given output.
|
Vector<Vector<PolyglotAuxiliary.Conversion<V,E>>> |
getShortestConversionPaths(String source_string,
String target_string)
Get the shortest list of the conversion tasks required to convert from a given input to a given output.
|
String |
getShortestConversionPathString(String source_string,
String target_string,
boolean ENABLE_WEIGHTED_PATHS)
Get the shortest list of the conversion tasks required to convert from a given input to a given output.
|
Vector<String> |
getShortestConversionPathStrings(String source_string,
String target_string)
Get the shortest list of the conversion tasks required to convert from a given input to a given output.
|
Vector<Integer> |
getShortestPaths(int source)
Perform a breadth first search from the vertex at the given index and store the resulting paths.
|
kgm.utility.Pair<Vector<Integer>,Vector<Double>> |
getShortestWeightedPaths(int source)
Perform Dijkstra's algorithm from the vertex at the given source index and store the resulting paths.
|
kgm.utility.Pair<Vector<Integer>,Vector<Double>> |
getShortestWeightedPathsOriginal(int source) |
TreeSet<E> |
getUniqueEdges()
Get a set of the unique edges in the graph.
|
TreeSet<String> |
getUniqueEdgeStrings()
Get the string representations for the unique edges in the graph.
|
Vector<String> |
getVertexStrings()
Get the string representations for the vertices.
|
Vector<String> |
getVertexStringsStartingWith(String prefix)
Get the string representations for the vertices that start with the given prefix.
|
Vector<V> |
getVertices()
Get the graph vertices.
|
void |
load(String filename)
Load graph from the given file.
|
void |
loadEdgeWeights(String filename,
Double invalid_value)
Load edge weights from the given file.
|
static void |
main(String... args) |
static void |
mainOriginal(String[] args)
A main for debug purposes.
|
void |
printEdgeInformation()
Display information about each unique edge.
|
void |
printEdgeInformation(E edge)
Display information about an edge.
|
void |
printMaxWeightedEdge()
Find the edge with the largest weight.
|
void |
printMinWeightedEdge()
Find the edge with the smallest weight.
|
void |
printMinWeightedVertex()
Find the vertex with the shortest combined traversed weight when visited from other vertices.
|
Vector<Vector<Boolean>> |
setActiveEdges(Boolean value)
Set all edges to the given value.
|
Vector<Vector<Boolean>> |
setActiveEdges(TreeSet<String> selected_edges)
Set only listed edges to active.
|
void |
setEdgeWeight(Double weight)
Sets the weight for all edges.
|
void |
setEdgeWeight(String source,
String target,
String edge,
Double weight)
Set the weight of the given edge.
|
void |
setMinimumWeight(double weight)
Sets the minimum weight a path can be to be considered path of the graph.
|
boolean |
showEdge(int source,
int target) |
static void |
timings(int edges,
int formats,
int software) |
void |
transformEdgeWeights(String expression)
Transform edge weights according to the given expression.
|
public static final long serialVersionUID
public IOGraph()
public IOGraph(SoftwareServerClient icr)
icr
- an ICR clientpublic IOGraph(String server, String user, String password)
server
- the server containing the databaseuser
- the user name to usepassword
- the password for this userpublic IOGraph(String url)
url
- the URL of the web scriptpublic void clear()
public int addVertex(V vertex)
vertex
- a vertex to addpublic void addEdge(V source, V target, E edge)
source
- the source vertextarget
- the target vertexedge
- the edgepublic void addEdge(V source, V target, E edge, Double w)
source
- the source vertextarget
- the target vertexedge
- the edgew
- the weight of the edgepublic void addEdgeOnce(V source, V target, E edge)
source
- the source vertextarget
- the target vertexedge
- the edgepublic void addGraph(IOGraph<V,E> iograph)
iograph
- another I/O-graphpublic Vector<Vector<Integer>> getAdjacencyList()
public Vector<Vector<Boolean>> setActiveEdges(Boolean value)
public Vector<Vector<Boolean>> setActiveEdges(TreeSet<String> selected_edges)
selected_edges
- a set of strings associated with selected edgespublic Vector<Boolean> getActiveVertices()
public Vector<Vector<Boolean>> getActiveEdges()
public Vector<String> getVertexStrings()
public Vector<String> getVertexStringsStartingWith(String prefix)
prefix
- the string vertex strings should start withpublic Vector<Vector<String>> getEdgeStrings()
public TreeSet<E> getUniqueEdges()
public TreeSet<String> getUniqueEdgeStrings()
public Vector<E> getParallelEdges(V source, V target, E edge)
source
- the source vertextarget
- the target vertexedge
- the actual edge (can be null)public double getMinimumWeight()
public void setMinimumWeight(double weight)
weight
- the minimum weight a path is allowed to be.public boolean showEdge(int source, int target)
public Double getMaxEdgeWeight(int v0, int v1)
v0
- the index of the starting vertexv1
- the index of the ending vertexpublic void setEdgeWeight(Double weight)
weight
- the weight for all edges.public void setEdgeWeight(String source, String target, String edge, Double weight)
source
- the source vertex stringtarget
- the target vertex stringedge
- the edge stringweight
- the weight for this edgepublic double getEdgeWeight(V input, V output, E edge)
input
- output
- edge
- public void load(String filename)
filename
- a file containing the graph as lines of: edge source target weightpublic void loadEdgeWeights(String filename, Double invalid_value)
filename
- a file containing lines with: edge source target weight (can be a URL)invalid_value
- the value to use for null weights (can be null indicating they should be ignored)public void transformEdgeWeights(String expression)
expression
- an expression to apply to all edge weightspublic Vector<Integer> getShortestPaths(int source)
source
- the index of the source vertexpublic kgm.utility.Pair<Vector<Integer>,Vector<Double>> dijkstra(int source)
source
- the node to start the search frompublic kgm.utility.Pair<Vector<Integer>,Vector<Double>> bellmanFord(int source) throws Exception
source
- the node to start the search fromwill
- throw an exception if a negative cycle is detectedException
public kgm.utility.Pair<Vector<Integer>,Vector<Double>> getShortestWeightedPaths(int source)
source
- the index of the source vertexpublic kgm.utility.Pair<Vector<Integer>,Vector<Double>> getShortestWeightedPathsOriginal(int source)
public String getPathString(Vector<Integer> path)
path
- the path from a source vertex to a target vertexpublic Vector<Double> getMaxPathWeights(Vector<Integer> path)
path
- the indices of the conversion pathpublic TreeSet<Integer> getRange(int index)
index
- the index of the source vertexpublic TreeSet<String> getRangeStrings()
public TreeSet<String> getRangeStrings(String string)
string
- string associated with the input vertexpublic TreeSet<Integer> getDomain(int target)
target
- the index of the target vertexpublic TreeSet<String> getDomainStrings()
public TreeSet<String> getDomainStrings(String target)
target
- the target vertex stringpublic TreeSet<Integer> getRangeIntersection(TreeSet<Integer> set)
set
- a set of vertex indicespublic TreeSet<String> getRangeIntersectionStrings(TreeSet<String> set)
set
- a set of vertex stringspublic PolyglotAuxiliary.Conversion<V,E> getConversion(String edge_string, String input_string, String output_string)
edge_string
- the string associated with the conversion edgeinput_string
- the inputoutput_string
- the outputpublic Vector<PolyglotAuxiliary.Conversion<V,E>> getConversions(String conversions_string)
conversions_string
- a string containing line separated conversions of the form: Application input outputpublic Vector<PolyglotAuxiliary.Conversion<V,E>> getShortestConversionPath(String source_string, String target_string, boolean ENABLE_WEIGHTED_PATHS)
source_string
- a string representing the input typetarget_string
- a string representing the output typeENABLE_WEIGHTED_PATHS
- use edge weights to determine conversion pathspublic String getShortestConversionPathString(String source_string, String target_string, boolean ENABLE_WEIGHTED_PATHS)
source_string
- a string representing the input typetarget_string
- a string representing the output typeENABLE_WEIGHTED_PATHS
- use edge weights to determine conversion pathspublic Vector<Vector<PolyglotAuxiliary.Conversion<V,E>>> getShortestConversionPaths(String source_string, String target_string)
source_string
- a string representing the input typetarget_string
- a string representing the output typepublic Vector<String> getShortestConversionPathStrings(String source_string, String target_string)
source_string
- a string representing the input typetarget_string
- a string representing the output typepublic static Vector<Integer> getPath(Vector<Integer> paths, int source, int target)
paths
- the single source shortest paths from the sourcesource
- the source vertextarget
- the destination vertexpublic IOGraph<String,String> getIOGraphStrings()
public void printMinWeightedEdge()
public void printMaxWeightedEdge()
public void printMinWeightedVertex()
public void printEdgeInformation()
public void printEdgeInformation(E edge)
edge
- the edge to display information aboutpublic void complexity()
public static void timings(int edges, int formats, int software)
public static void main(String... args)
public static void mainOriginal(String[] args)
args
- command line argumentsCopyright © 2014. All rights reserved.