Salt
3.4.2
A powerful, tagset-independent and theory-neutral meta model and API for storing, manipulating, and representing nearly all types of linguistic data .
|
Handles the traversal of a graph. More...
Classes | |
class | Traverser |
A threadable class, which traverses the graph and invokes methods of the given callback handler during the traversal. | |
Public Member Functions | |
SGraph | getGraph () |
void | setGraph (SGraph graph) |
void | traverse (List< SNode > startNodes, GRAPH_TRAVERSE_TYPE traverseType, String traverseId, GraphTraverseHandler traverseHandler) |
Traverses a graph in the given order traverseType and starts traversing with the given startNodes. More... | |
void | traverse (List<? extends SNode > startNodes, GRAPH_TRAVERSE_TYPE traverseType, String traverseId, GraphTraverseHandler traverseHandler, boolean isCycleSafe) |
Traverses a graph in the given order traverseType and starts traversing with the given startNodes. More... | |
Protected Attributes | |
SGraph | graph = null |
Handles the traversal of a graph.
void org.corpus_tools.salt.core.impl.GraphTraverserModule.traverse | ( | List< SNode > | startNodes, |
GRAPH_TRAVERSE_TYPE | traverseType, | ||
String | traverseId, | ||
GraphTraverseHandler | traverseHandler | ||
) |
Traverses a graph in the given order traverseType and starts traversing with the given startNodes.
When a node is reached, first this method will invoke the method GraphTraverseHandler#checkConstraint(GRAPH_TRAVERSE_TYPE, String, SRelation, SNode, long) of the given callback handler traverseHandler, second the method GraphTraverseHandler#nodeReached(GRAPH_TRAVERSE_TYPE, String, SNode, SRelation, SNode, long) is invoked. When a node was left, the method GraphTraverseHandler#nodeLeft(GRAPH_TRAVERSE_TYPE, String, SNode, SRelation, SNode, long) is invoked. When calling these methods, the traverseId will be passed, so that the callback handler knows which traversal is meant. This is helpful, in case of a single callback handler is used for more than one traversal at the same time. This method throws a SaltInvalidModelException in case of the graph contains a cycle. A cycle means a path containing the same node twice. Cycle safe breadth first traversing could consume a lot of memory because the algorithm keeps a map of all visited Nodes for every start node.
startNodes | list of nodes at which the traversal shall start |
traverseType | type of traversing |
traverseId | identification for callback handler, in case of more than one traversal is running at the same time with the same callback handler |
traverseHandler | callback handler, on which the three methods will be invoked |
void org.corpus_tools.salt.core.impl.GraphTraverserModule.traverse | ( | List<? extends SNode > | startNodes, |
GRAPH_TRAVERSE_TYPE | traverseType, | ||
String | traverseId, | ||
GraphTraverseHandler | traverseHandler, | ||
boolean | isCycleSafe | ||
) |
Traverses a graph in the given order traverseType and starts traversing with the given startNodes.
When a node is reached, first this method will invoke the method GraphTraverseHandler#checkConstraint(GRAPH_TRAVERSE_TYPE, String, SRelation, SNode, long) of the given callback handler traverseHandler, second the method GraphTraverseHandler#nodeReached(GRAPH_TRAVERSE_TYPE, String, SNode, SRelation, SNode, long) is invoked. When a node was left, the method GraphTraverseHandler#nodeLeft(GRAPH_TRAVERSE_TYPE, String, SNode, SRelation, SNode, long) is invoked. When calling these methods, the traverseId will be passed, so that the callback handler knows which traversal is meant. This is helpful, in case of a single callback handler is used for more than one traversal at the same time. This method throws a SaltInvalidModelException in case of the graph contains a cycle. A cycle means a path containing the same node twice. Cycle safe breadth first traversing could consume a lot of memory because the algorithm keeps a map of all visited Nodes for every start node.
startNodes | list of nodes at which the traversal shall start |
traverseType | type of traversing |
traverseId | identification for callback handler, in case of more than one traversal is running at the same time with the same callback handler |
traverseHandler | callback handler, on which the three methods will be invoked |
isCycleSafe | if this value is false, this method does not take care about cycles. This can invoke endless loops. |