libSmalldb  v2.0.2
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GraphSearch Class Reference

Description

Depth First Search & friends.

Public Member Functions

 runForward ()
 
 runBackward ()
 
 runBothWays ()
 
 onNode (?callable $callback)
 Call $func when entering the node. More...
 
 onEdge (?callable $callback)
 Call $func when inspecting next nodes, before enqueuing them. More...
 
 start (array $startNodes)
 Start DFS from $startNodes. More...
 

Static Public Member Functions

static DFS (NestedGraph $g)
 
static BFS (NestedGraph $g)
 

Public Attributes

const DFS_STRATEGY = 0x01
 
const BFS_STRATEGY = 0x02
 
const DIR_FORWARD = 0x10
 
const DIR_BACKWARD = 0x20
 
const DIR_BOTH = 0x30
 

Member Function Documentation

◆ DFS()

static DFS ( NestedGraph  $g)
static

◆ BFS()

static BFS ( NestedGraph  $g)
static

◆ runForward()

runForward ( )

◆ runBackward()

runBackward ( )

◆ runBothWays()

runBothWays ( )

◆ onNode()

onNode ( ?callable  $callback)

Call $func when entering the node.

Parameters
callable$callbackfunction(Node $current_node)

◆ onEdge()

onEdge ( ?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
callable$callbackfunction(Node $current_node, Edge $edge, Node $next_node, bool $next_node_seen)

◆ start()

start ( array  $startNodes)

Start DFS from $startNodes.

Parameters
Node[]$startNodes List of starting nodes or their IDs.
See also
Node $currentNode

Member Data Documentation

◆ DFS_STRATEGY

const DFS_STRATEGY = 0x01

◆ BFS_STRATEGY

const BFS_STRATEGY = 0x02

◆ DIR_FORWARD

const DIR_FORWARD = 0x10

◆ DIR_BACKWARD

const DIR_BACKWARD = 0x20

◆ DIR_BOTH

const DIR_BOTH = 0x30