-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetwork.php
More file actions
69 lines (61 loc) · 2.14 KB
/
Network.php
File metadata and controls
69 lines (61 loc) · 2.14 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
<?php
namespace Stratadox\Pathfinder;
use InvalidArgumentException;
/**
* Network.
*
* A network is a collection of nodes that are connected through edges.
*
* @api
* @author Stratadox
*/
interface Network
{
/**
* Retrieves the labels of all of the nodes that are in the network.
*
* @return Labels The labels of all the nodes in the network.
*/
public function all(): Labels;
/**
* Retrieves the labels of the neighbours of the node with the given label.
*
* @param string $node The label of the node whose neighbours to retrieve.
* @return Labels The labels of the neighbouring nodes.
*/
public function neighboursOf(string $node): Labels;
/**
* Checks whether the nodes are neighbours.
*
* Note that the network is directed by default: as such this operation is
* not necessarily symmetric: A can be a neighbour of B, without B being a
* neighbour of A.
*
* @param string $source The label that identifies the source node.
* @param string $neighbour The label that identifies the potential neighbour.
* @return bool Whether the nodes are neighbours.
*/
public function areNeighbours(string $source, string $neighbour): bool;
/**
* Checks whether a node with the given label exists in the network.
*
* @param string $node The label to look for.
* @return bool Whether the label is present.
*/
public function has(string $node): bool;
/**
* Retrieves the movement cost between two neighbours.
*
* @param string $source The label of the source node.
* @param string $neighbour The label of the neighbouring node.
* @return float The cost of the edge.
* @throws InvalidArgumentException When the nodes are not neighbours.
*/
public function movementCostBetween(string $source, string $neighbour): float;
/**
* Checks whether the network contains negative edge costs.
*
* @return bool Whether the network contains edges with negative costs.
*/
public function hasNegativeEdgeCosts(): bool;
}