Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | protected function dfs(int $vertex) |
||
17 | { |
||
18 | // we have visited now |
||
19 | $this->marked[$vertex] = true; |
||
20 | // set the component # |
||
21 | $this->id[$vertex] = $this->count; |
||
22 | // bump up the size of this component |
||
23 | $this->size[$this->count]++; |
||
24 | // get the neighbors |
||
25 | $neighbors = $this->graph->adjacent($vertex); |
||
26 | // iterate over the neighbors |
||
27 | foreach ($neighbors as $w) { |
||
28 | // /check if we have visited this vertex |
||
29 | if (!$this->marked[$w]) { |
||
30 | // we have not, lets visit with dfs |
||
31 | $this->dfs($w); |
||
32 | } |
||
36 |