UCC   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A dfs() 0 16 3
1
<?php
2
3
namespace TemplesOfCode\NodesAndEdges\DFS;
4
5
/**
6
 * Class UCC
7
 * @package TemplesOfCode\NodesAndEdges\DFS
8
 */
9
class UCC extends ConnectedComponent
10
{
11
    /**
12
     * Depth-first search for a Graph
13
     *
14
     * @param $vertex
15
     */
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
            }
33
        }
34
    }
35
}
36