Package com.tietoenator.trip.jxp.graph
Class TdbGraphSet
java.lang.Object
com.tietoenator.trip.jxp.graph.TdbGraphSet
- Direct Known Subclasses:
TdbSubGraph
Represents a graph database, a graph cluster or a subgraph based on a
graph query.
THIS CLASS IS EXPERIMENTAL. USE WITH CAUTION! ITS INTERFACE MAY CHANGE IN FUTURE RELEASES.
- Since:
- TRIPjxp 3.1
-
Method Summary
Modifier and TypeMethodDescriptionCreates a subgraph by following a particular edge type backwards from target vertex in the current graph set to source vertex in the specified source set.Locate all paths associated with the current graph set that use vertices in the specified start set as origins.Creates a subgraph by locating targets for the source vertices in the current graph set such that they are related via a particular edge (a.k.a. relation, link).int
Returns the count of edges in this graph set.getGraph()
Returns the TdbGraph instance that this graph set is associated with.getRecord
(int index) Returns a TdbGraphRecord object for a record in the the current graph set.int
Returns the TRIP search set ID for this graph set.merge
(TdbGraphSet otherSet) Merge this graph set with another, producing the union of both sets.Execute a query using the TRIP graph query language.Resolve target vertices to a search set of the regular records they represent.Resolve target vertices to a search set of the regular records they represent.shortestPath
(int startSet, String[] edgeNames, int targetSet) Determine the shortest path associated with the current graph set that use vertices in the specified start set as origins.source
(int searchSet) Create a subgraph with edges where source vertices can be found in the specified (regular) search set.target
(int searchSet) Create a subgraph with edges where target vertices can be found in the specified (regular) search set.transitive
(int sourceSet, int targetSet, String[] edgeNames, int maxDepth, boolean reverse, boolean allEdges) Creates a subgraph of the current graph set where the specified source and target records are connected via path.
-
Method Details
-
getGraph
Returns the TdbGraph instance that this graph set is associated with. -
getSearchId
public int getSearchId()Returns the TRIP search set ID for this graph set. -
getEdgeCount
public int getEdgeCount()Returns the count of edges in this graph set.- Returns:
- Edge count
-
getRecord
Returns a TdbGraphRecord object for a record in the the current graph set.- Parameters:
index
- The zero-based index of the record in the set.- Returns:
- A TdbGraphRecord instance
- Throws:
TdbException
-
source
Create a subgraph with edges where source vertices can be found in the specified (regular) search set.- Parameters:
searchSet
- Normal search set to find outgoing edges for.- Returns:
- A TdbGraphSet instance for the resulting subgraph
- Throws:
TdbException
-
target
Create a subgraph with edges where target vertices can be found in the specified (regular) search set.- Parameters:
searchSet
- Normal search set to find incoming edges for.- Returns:
- A TdbGraphSet instance for the resulting subgraph
- Throws:
TdbException
-
follow
Creates a subgraph by locating targets for the source vertices in the current graph set such that they are related via a particular edge (a.k.a. relation, link).- Parameters:
edge
- Name of edge (a.k.a. relation, link) to followtargetSet
- Positive search set number (from regular database)- Returns:
- A TdbGraphSet instance for the resulting subgraph
- Throws:
TdbException
-
backtrack
Creates a subgraph by following a particular edge type backwards from target vertex in the current graph set to source vertex in the specified source set.- Parameters:
edge
- Name of edge (a.k.a. relation, link) to follow backwardssourceSet
- Positive search set number (from regular database)- Returns:
- A TdbGraphSet instance for the resulting subgraphs
- Throws:
TdbException
-
resolveTargets
Resolve target vertices to a search set of the regular records they represent.- Returns:
- A TRIP search set with the records targeted by the edges in the current graph set.
- Throws:
TdbException
-
resolveSources
Resolve target vertices to a search set of the regular records they represent.- Returns:
- A TRIP search set with the records being targets for the edges in the current graph set.
- Throws:
TdbException
-
transitive
public TdbGraphSet transitive(int sourceSet, int targetSet, String[] edgeNames, int maxDepth, boolean reverse, boolean allEdges) throws TdbException Creates a subgraph of the current graph set where the specified source and target records are connected via path.- Parameters:
sourceSet
- The positive number for a regular search set that specifies the source vertices (must not be zero).targetSet
- The positive number for a regular search set that specifies the target vertices (or zero to locate all potential targets)edgeNames
- An array of names of the edge types to traverse - pass null or an empty array to traverse all edge types.maxDepth
- The maximum depth to search - pass zero for no depth limitreverse
- Pass true to do transitive search by following edges in reverse direction.allEdges
- Pass true to retrieve all edges explored by the operation, and false to only retrieve the final, outer edges.- Returns:
- A TdbGraphSet object
- Throws:
TdbException
-
query
Execute a query using the TRIP graph query language.- Parameters:
expression
- Query expression in TRIP graph query language syntax.- Returns:
- An instance of TdbGraphSet if the query results in an edge set, or an instance of TdbSearchSet if the query results in an edge set.
- Throws:
TdbException
-
findPaths
public TdbGraphPath[] findPaths(int startSet, String[] edgeNames, int targetSet, int maxDepth, boolean reverse) throws TdbException Locate all paths associated with the current graph set that use vertices in the specified start set as origins. This is a so-called "NP hard" problem, and as such this operation may take a long time to complete for large graphs.- Parameters:
startSet
- Regular search set specifying the vertex record(s) to use as starting point(s) for the paths.edgeNames
- Names of edges to follow or pass null or an empty array to follow all edges.targetSet
- Regular search set specifying the vertex record(s) to use as end point(s) for the paths.maxDepth
- The maximum traversal depth or pass zero for no limit.reverse
- Pass true to explore paths in reverse direction.- Returns:
- An array of graph paths
- Throws:
TdbException
-
shortestPath
public TdbGraphPath shortestPath(int startSet, String[] edgeNames, int targetSet) throws TdbException Determine the shortest path associated with the current graph set that use vertices in the specified start set as origins. This is a so-called "NP hard" problem, and as such this operation may take a long time to complete for large graphs.- Parameters:
startSet
- Regular search set specifying the vertex record(s) to use as starting point for the paths.edgeNames
- Names of edges to follow or pass null or an empty array to follow all edges.targetSet
- Regular search set specifying the vertex record(s) to use as end points for the paths.- Returns:
- The shortest path found in the graph between the target and the source, or null if no path was found.
- Throws:
TdbException
-
merge
Merge this graph set with another, producing the union of both sets.- Parameters:
otherSet
- Other graph set to merge with.- Returns:
- Merged graph set
- Throws:
TdbException
-