Completed
Push — master ( 42e858...e23440 )
by Siro Díaz
02:43
created

DisjointNode   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 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 $rank;
25
    public $data;
26
27
    public function __construct($rank, $data) {
28
        $this->parent = null;
29
        $this->rank = $rank;
30
        $this->data = $data;
31
    }
32
}