From: Finding relevant semantic association paths through user-specific intermediate entities
Modified Bidirectional Breadth-First Search Algorithm |
---|
Input: RDF Graph and user query as entity |
Output: Semantic Association paths without ranking |
/**Path searching for finding all paths at within k hops */ |
1. Enqueue the root node in the forward queue: the source Thing in the path we want to discover |
2. Enqueue the target node in the backward queue: the destination Thing in the path we want to discover |
3. Dequeue a forward node and examine it |
    a. If the forward node is found in the backward zone//we have met in the middle: quit the search |
a.1 If the path passes through user specific intermediate node return the complete path |
a.2 quit the search |
    b. Otherwise enqueue any successors that have not yet been examined in the forward queue and add them to the forward zone |
4. Dequeue a backward node and examine it |
    a. If the backward node is found in the forward zone//we have met in the middle |
a.1 If the path passes through user specific intermediate node return the complete path |
a.2 quit the search |
    b. Otherwise enqueue any predecessors that have not yet been examined in the backward queue and add them to the backward zone |
5. If the any of the two queues is empty, every node on the graph has been examined, quit the search and return "not found" |
6. If we are still under the depth limit, repeat from Step 3 |