src/Hal/Component/Tree/Operator/SizeOfTree.php
public function getNumberOfChilds(Node $node, $uniqs = false)
    {

        $edges = $node->getEdges();

        if (0 === sizeof($edges)) {
            return 0;
        }

        // our tree is not binary : interface can have more than one parent
        $max = 0;
        $n = 0;

        foreach ($edges as $edge) {


            if ($edge->getTo() == $node) {
                continue;
            }

            if (true == $uniqs && $edge->getTo()->visited) {
                continue;
            }
            $edge->getTo()->visited = true;

            $n += 1 + $this->getNumberOfChilds($edge->getTo(), $uniqs);

            $edge->getTo()->visited = false;


            if ($n > $max) {
                $max = $n;
            }
        }

        return $max;
    }
public function getNumberOfChilds(Node $node, $uniqs = false)
    {

        $edges = $node->getEdges();

        if (0 === sizeof($edges)) {
            return 0;
        }

        // our tree is not binary : interface can have more than one parent
        $max = 0;
        $n = 0;

        foreach ($edges as $edge) {


            if ($edge->getTo() == $node) {
                continue;
            }

            if (true == $uniqs && $edge->getTo()->visited) {
                continue;
            }
            $edge->getTo()->visited = true;

            $n += 1 + $this->getNumberOfChilds($edge->getTo(), $uniqs);

            $edge->getTo()->visited = false;


            if ($n > $max) {
                $max = $n;
            }
        }

        return $max;
    }
Get depth of node

@param Node $node
@return int