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 .
org.corpus_tools.salt.core.impl.GraphTraverserModule Class Reference

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
 

Detailed Description

Handles the traversal of a graph.

Author
Florian Zipser

Member Function Documentation

◆ traverse() [1/2]

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.

Parameters
startNodeslist of nodes at which the traversal shall start
traverseTypetype of traversing
traverseIdidentification for callback handler, in case of more than one traversal is running at the same time with the same callback handler
traverseHandlercallback handler, on which the three methods will be invoked

◆ traverse() [2/2]

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.

Parameters
startNodeslist of nodes at which the traversal shall start
traverseTypetype of traversing
traverseIdidentification for callback handler, in case of more than one traversal is running at the same time with the same callback handler
traverseHandlercallback handler, on which the three methods will be invoked
isCycleSafeif this value is false, this method does not take care about cycles. This can invoke endless loops.