-  Documented `dfs(...)`
This commit is contained in:
Tristan B. Velloza Kildaire 2024-05-04 10:38:41 +02:00
parent 6b91fb0f20
commit c3287bf474
1 changed files with 24 additions and 0 deletions

View File

@ -948,6 +948,30 @@ public class Graph(T)
return this.length;
}
/**
* Performs a depth first search
* on the graph by firstly calling
* the `TouchStratergy` on the current
* node and then iterating over all
* of its children and only recursing
* on each of them if the `InclusionStratergy`
* allows it.
*
* The touch stratergy is called
* as part of the first line of code
* in the call to the dfs on a
* given graph node.
*
* Note that is you don't have a good
* inclusion stratergy and touch startergy
* then you may have a stack overflow
* occur if your graph has cycles
*
* Params:
* strat = the `InclusionStratergy`
* touch = the `TouchStratergy`
* Returns: a `T[]`
*/
public T[] dfs
(
InclusionStratergy!(T) strat = toDelegate(&Always!(T)),