Completed
Push — development ( 2d042e...b2c933 )
by Dylan David
01:38
created

FibonacciHeap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A insert() 0 2 1
1
<?php
2
3
namespace Ptypes;
4
5
6
//NOTES:
7
/*
8
9
n = number of nodes in heap
10
11
rank(x) = number of children of node x
12
13
rank(H) = max rank of any node in heap H
14
15
tree(H) = number of trees in heap H
16
17
marks(H) = number of marked nodes in heap H
18
19
potential of heap (H) = trees(H) + 2 * marks(H)
20
21
22
23
operations:
24
-make fib heap: returns empty heap
25
26
-insert: inserts node x whose key field has already been filled in, into the heap
27
28
-minimum: returns a pointer to the node with the minimum key in heap H
29
30
-extract-min: deletes the node with the minimum key in heap H, returns a pointer to the node
31
32
-UNION(H1, H2): creates and returns a new heap that contains all the nodes of H1 and H2, H1 & H2 are destroyed by this operation
33
34
-descrease-key(x, k): assigns to node x within the heap H the new key value K, it is assumed that the key <= x: key
35
36
-delete(x): deletes node x from heap H
37
*/
38
39
class FibonacciHeap
40
{
41
	private $n; //numberr of nodes in heap
42
	private $min; //pointer to node with minimum key in heap
43
	private $trees; //trees in the heap
44
	private $roots;
0 ignored issues
show
introduced by
The private property $roots is not used, and could be removed.
Loading history...
45
	
46
	public function __construct() //cost: O(1)
47
	{
48
		$this->n = 0;
49
		$this->trees = 0;
50
		$this->min = null;
51
	}
52
	
53
	public function insert($x) //x = node
0 ignored issues
show
Unused Code introduced by
The parameter $x is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

53
	public function insert(/** @scrutinizer ignore-unused */ $x) //x = node

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
54
	{
55
		//https://www.slideshare.net/anshumanbiswal/fibonacci-heap-15765216
56
		//todo
57
		//create tree
58
		//todo
59
	}
60
}