\GraphDS\AlgoDFS

Class defining depth-first 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 DFS order.

Type

array

Methods

__construct()

__construct(object  $graph) 

Constructor for the DFS algorithm.

Parameters

object $graph

The graph to which the DFS algorithm should be applied

Throws

\InvalidArgumentException

run()

run(mixed  $root) 

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

Parameters

mixed $root

ID of the vertex from which the DFS should begin

get()

get() : array

Returns the result of the DFS.

Returns

array —

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