DisjointNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * DataStructures for PHP
4
 *
5
 * @link      https://github.com/SiroDiaz/DataStructures
6
 * @copyright Copyright (c) 2017 Siro Díaz Palazón
7
 * @license   https://github.com/SiroDiaz/DataStructures/blob/master/README.md (MIT License)
8
 */
9
namespace DataStructures\Trees\Nodes;
10
11
/**
12
 * DisjointNode.
13
 *
14
 * The DisjointNode class represents the disjoint set node. It uses a pointer to the
15
 * next parent node and a rank attribute used to add the little tree to the bigger.
16
 * The trees with just one element have a rank of 0.
17
 * Using rank the execution time for operations makeSet, union, and find is of O(log n).
18
 * Rank is used instead of depth.
19
 *
20
 * @author Siro Diaz Palazon <[email protected]>
21
 */
22
class DisjointNode {
23
    public $parent;
24
    public $data;
25
26
    public function __construct($data) {
27
        $this->parent = null;
28
        $this->data = $data;
29
    }
30
}