1 | <?php |
||
16 | class Graph { |
||
17 | /** |
||
18 | * @var array<int, Node> |
||
19 | */ |
||
20 | protected $nodes = []; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $id_counter = 0; |
||
26 | |||
27 | /** |
||
28 | * Create a new node in the graph. |
||
29 | * |
||
30 | * @param string $type |
||
31 | * @param array<string,mixed> $properties |
||
32 | * @return Node |
||
33 | */ |
||
34 | 67 | public function create_node($type, array $properties) { |
|
40 | |||
41 | 67 | protected function build_node($id, $type, array $properties) { |
|
44 | |||
45 | /** |
||
46 | * Add a relation to the graph. |
||
47 | * |
||
48 | * @param Node $left |
||
49 | * @param string $type |
||
50 | * @param array<string,mixed> $properties |
||
51 | * @param Node $right |
||
52 | * @return Relation |
||
53 | */ |
||
54 | 53 | public function add_relation(Node $left, $type, array $properties, Node $right) { |
|
57 | |||
58 | /** |
||
59 | * Get nodes from the graph, maybe filtered by a filter. |
||
60 | * |
||
61 | * @param \Closure|null $filter |
||
62 | * @return Node[] |
||
63 | */ |
||
64 | 64 | public function nodes(\Closure $filter = null) { |
|
70 | |||
71 | /** |
||
72 | * Get the node with the given id. |
||
73 | * |
||
74 | * @param int $id |
||
75 | * @throws \InvalidArgumentException if $id is unknown |
||
76 | * @return Node |
||
77 | */ |
||
78 | 1 | public function node($id) { |
|
85 | |||
86 | /** |
||
87 | * Build a query on the graph. |
||
88 | * |
||
89 | * @return Query |
||
90 | */ |
||
91 | 7 | public function query() { |
|
94 | } |
||
95 |