protected function normalize($default)
    {
        if ($this->is('empty')) {
            return;
        }

        $maxCols = array_reduce(
                $this->data,
                function($carry, $item) {
                    $l = count($item);
                    return ($l > $carry ? $l : $carry);
                },
                0);

        array_walk(
                $this->data,
                function(&$row) use ($maxCols, $default) {
                    if (($len = count($row)) < $maxCols) {
                        $row += array_fill($len, $maxCols - $len, $default);
                    }
                });
    }
protected function normalize($default)
    {
        if ($this->is('empty')) {
            return;
        }

        $maxCols = array_reduce(
                $this->data,
                function($carry, $item) {
                    $l = count($item);
                    return ($l > $carry ? $l : $carry);
                },
                0);

        array_walk(
                $this->data,
                function(&$row) use ($maxCols, $default) {
                    if (($len = count($row)) < $maxCols) {
                        $row += array_fill($len, $maxCols - $len, $default);
                    }
                });
    }
protected function normalize ( $ default ) { if ( $ this -> is ( 'empty' ) ) { return ; } $ maxCols = array_reduce ( $ this -> data , function ( $ carry , $ item ) { $ l = count ( $ item ) ; return ( $ l > $ carry ? $ l : $ carry ) ; } , 0 ) ; array_walk ( $ this -> data , function ( & $ row ) use ( $ maxCols , $ default ) { if ( ( $ len = count ( $ row ) ) < $ maxCols ) { $ row += array_fill ( $ len , $ maxCols - $ len , $ default ) ; } } ) ; }
Normalize matrix to have same number of columns for each row
Missing vertices are set with default value

@param mixed $default default value to set
Normalize matrix to have same number of columns for each row Missing vertices are set with default value