1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Stratadox\Pathfinder\Graph; |
4
|
|
|
|
5
|
|
|
use Stratadox\Pathfinder\Environment; |
6
|
|
|
use Stratadox\Pathfinder\Network; |
7
|
|
|
use Stratadox\Pathfinder\Labels; |
8
|
|
|
use Stratadox\Pathfinder\Position; |
9
|
|
|
|
10
|
|
|
final class GeometricView implements Environment |
11
|
|
|
{ |
12
|
|
|
private $actualGraph; |
13
|
|
|
|
14
|
|
|
private function __construct(Network $actualGraph) |
15
|
|
|
{ |
16
|
|
|
$this->actualGraph = $actualGraph; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public static function of(Network $actualGraph): Environment |
20
|
|
|
{ |
21
|
|
|
if ($actualGraph instanceof Environment) { |
22
|
|
|
return $actualGraph; |
23
|
|
|
} |
24
|
|
|
return new self($actualGraph); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function all(): Labels |
28
|
|
|
{ |
29
|
|
|
return $this->actualGraph->all(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function positionOf(string $node): Position |
33
|
|
|
{ |
34
|
|
|
return At::position(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function neighboursOf(string $node): Labels |
38
|
|
|
{ |
39
|
|
|
return $this->actualGraph->neighboursOf($node); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function areNeighbours(string $source, string $neighbour): bool |
43
|
|
|
{ |
44
|
|
|
return $this->actualGraph->areNeighbours($source, $neighbour); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function has(string $node): bool |
48
|
|
|
{ |
49
|
|
|
return $this->actualGraph->has($node); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function movementCostBetween(string $source, string $neighbour): float |
53
|
|
|
{ |
54
|
|
|
return $this->actualGraph->movementCostBetween($source, $neighbour); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function hasNegativeEdgeCosts(): bool |
58
|
|
|
{ |
59
|
|
|
return $this->actualGraph->hasNegativeEdgeCosts(); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|