\GraphDS\AlgoBFS

Class defining the breadth-dirst search.

Summary

Methods
Properties
Constants
__construct()
run()
get()
$graph
$dist
$parent
$discovered
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$graph

$graph : object

Reference to the graph.

Type

object

$dist

$dist : array

Distances for each node to root in hops.

Type

array

$parent

$parent : array

Parents for each vertex.

Type

array

$discovered

$discovered : array

Discovered vertices, in BFS order.

Type

array

Methods

__construct()

__construct(object  $graph) 

Constructor for the BFS algorithm.

Parameters

object $graph

The graph to which the BFS algorithm should be applied

run()

run(mixed  $root) 

Runs the BFS from a given vertex $vertex on the graph.

Parameters

mixed $root

ID of the vertex from which the BFS should begin

get()

get() : array

Returns the result of the BFS.

Returns

array —

Array of vertex distance to root, parents and vertices in BFS order