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