libSmalldb  v0.7
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GraphSearch Class Reference

Description

Depth First Search & friends.

Public Member Functions

 onNode (callable $callback)
 Call $func when entering the node. More...
 
 onArrow (callable $callback)
 Call $func when inspecting next nodes, before enqueuing them. More...
 
 start ($start_nodes)
 Start DFS from $startNodes. More...
 

Static Public Member Functions

static DFS (Graph $g)
 
static BFS (Graph $g)
 

Public Attributes

const DFS_STRATEGY = 1
 
const BFS_STRATEGY = 2
 

Member Function Documentation

onNode ( callable  $callback)

Call $func when entering the node.

Parameters
$callbackfunction($current_node_id)
onArrow ( callable  $callback)

Call $func when inspecting next nodes, before enqueuing them.

Nodes are inspected always, even when they have been seen before, but once seen nodes are not enqueued again.

Parameters
$callbackfunction($current_node_id, $next_node_id, $next_node_seen, $arrow_id)
Returns
True if the $next_node_id should be engueued for processing. The node will not be enqueued if it was already visited.
start (   $start_nodes)

Start DFS from $startNodes.

Parameters
$startNodesList of starting nodes or their IDs.
$nextNodesMap $current_node_id -> list of [ $next_node_id, $arrow_id ].