-
Notifications
You must be signed in to change notification settings - Fork 177
Expand file tree
/
Copy pathgraphnode.php
More file actions
99 lines (85 loc) · 3.31 KB
/
Copy pathgraphnode.php
File metadata and controls
99 lines (85 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
// This file is part of Stack - http://stack.maths.ed.ac.uk/
//
// Stack is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Stack is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
/**
* Class to represtent a vertex in an abstract representation of a PRT.
*
* @package qtype_stack
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Represents a node in a {@link stack_abstract_graph}.
*
* @package qtype_stack
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class stack_abstract_graph_node {
/** @var string indentifier for this node. */
public $name;
/** @var string description for this node. */
public $description;
/** @var string identifier of the left child. */
public $left;
/** @var string identifier of the right child. */
public $right;
/** @var string label on the left edge. */
public $leftlabel = '';
/** @var string label on the left edge. */
public $rightlabel = '';
/** @var string $url if set, this node should be a link to that URL. */
public $url = '';
/** @var int depth of this node in the display. */
public $depth = null;
/**
* @var int x-coordinate to display this node at. (Actually, may be a float
* at during the layout algorithm, but becomes an int in the end.)
*/
public $x = 0;
/**
* @var float. Used during the layout algorithm. See
* {@link stack_abstract_graph::compute_heuristic_xs()}.
*/
public float $heuristicsum;
/**
* @var float. Used during the layout algorithm. See
* {@link stack_abstract_graph::compute_heuristic_xs()}.
*/
public float $heuristiccount;
/**
* Constructor.
* @param string $name name of this node.
* @param string $description description for this node.
* @param string $left name of the left child.
* @param string $right name of the right child.
* @param string $leftlabel lable to display on the edge to the left child.
* @param string $rightlabel lable to display on the edge to the right child.
* @param string $url if set, this node should be a link to that URL.
*/
public function __construct($name, $description, $left, $right, $leftlabel = '', $rightlabel = '', $url = '') {
$this->name = $name;
$this->description = $description;
$this->left = $left;
$this->right = $right;
$this->leftlabel = $leftlabel;
$this->rightlabel = $rightlabel;
$this->url = $url;
}
// phpcs:ignore moodle.Commenting.MissingDocblock.Function
public function __toString() {
return '[' . $this->name . ' (' . $this->x . ', ' . $this->depth . '): -> ' . $this->left . ', -> ' . $this->right . ']';
}
}