Skip to content

Commit 9bf3cf9

Browse files
authored
Merge pull request #172 from clue-labs/docs
Minor documentation updates
2 parents b744a33 + 290ed9f commit 9bf3cf9

9 files changed

Lines changed: 51 additions & 37 deletions

File tree

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@
22

33
GraPHP is the mathematical graph/network library written in PHP.
44

5+
**Table of contents**
6+
7+
* [Quickstart examples](#quickstart-examples)
8+
* [Features](#features)
9+
* [Components](#components)
10+
* [Graph drawing](#graph-drawing)
11+
* [Common algorithms](#common-algorithms)
12+
* [Install](#install)
13+
* [Tests](#tests)
14+
* [Contributing](#contributing)
15+
* [License](#license)
16+
517
## Quickstart examples
618

719
Once [installed](#install), let's initialize a sample graph:
820

9-
````php
21+
```php
1022
<?php
11-
require_once 'vendor/autoload.php';
1223

1324
use \Fhaculty\Graph\Graph as Graph;
1425

26+
require_once 'vendor/autoload.php';
27+
1528
$graph = new Graph();
1629

1730
// create some cities
@@ -24,15 +37,16 @@ $cologne->createEdgeTo($madrid);
2437
$madrid->createEdgeTo($rome);
2538
// create loop
2639
$rome->createEdgeTo($rome);
27-
````
40+
```
41+
42+
Let's see which city (Vertex) has a road (i.e. an edge pointing) to Rome:
2843

29-
Let's see which city (Vertex) has road (i.e. an edge pointing) to Rome
30-
````php
44+
```php
3145
foreach ($rome->getVerticesEdgeFrom() as $vertex) {
3246
echo $vertex->getId().' leads to rome'.PHP_EOL;
3347
// result: Madrid and Rome itself
3448
}
35-
````
49+
```
3650

3751
## Features
3852

src/Edge/Base.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract public function getVerticesStart();
5959
* return true if this edge is an outgoing edge of the given vertex (i.e. the given vertex is a valid start vertex of this edge)
6060
*
6161
* @param Vertex $startVertex
62-
* @return boolean
62+
* @return bool
6363
* @uses Vertex::getVertexToFrom()
6464
*/
6565
abstract public function hasVertexStart(Vertex $startVertex);
@@ -68,7 +68,7 @@ abstract public function hasVertexStart(Vertex $startVertex);
6868
* return true if this edge is an ingoing edge of the given vertex (i . e. the given vertex is a valid end vertex of this edge)
6969
*
7070
* @param Vertex $targetVertex
71-
* @return boolean
71+
* @return bool
7272
* @uses Vertex::getVertexFromTo()
7373
*/
7474
abstract function hasVertexTarget(Vertex $targetVertex);
@@ -78,7 +78,7 @@ abstract public function isConnection(Vertex $from, Vertex $to);
7878
/**
7979
* returns whether this edge is actually a loop
8080
*
81-
* @return boolean
81+
* @return bool
8282
*/
8383
abstract public function isLoop();
8484

src/Graph.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getEdges()
5757
* create a new Vertex in the Graph
5858
*
5959
* @param int|NULL $id new vertex ID to use (defaults to NULL: use next free numeric ID)
60-
* @param boolean $returnDuplicate normal operation is to throw an exception if given id already exists. pass true to return original vertex instead
60+
* @param bool $returnDuplicate normal operation is to throw an exception if given id already exists. pass true to return original vertex instead
6161
* @return Vertex (chainable)
6262
* @throws InvalidArgumentException if given vertex $id is invalid
6363
* @throws OverflowException if given vertex $id already exists and $returnDuplicate is not set
@@ -308,7 +308,7 @@ public function getVertex($id)
308308
* checks whether given vertex ID exists in this graph
309309
*
310310
* @param int|string $id identifier of Vertex
311-
* @return boolean
311+
* @return bool
312312
*/
313313
public function hasVertex($id)
314314
{
@@ -320,7 +320,7 @@ public function hasVertex($id)
320320
*
321321
* @param Vertex $vertex instance of the new Vertex
322322
* @return void
323-
* @private
323+
* @internal
324324
* @see self::createVertex() instead!
325325
*/
326326
public function addVertex(Vertex $vertex)
@@ -336,7 +336,7 @@ public function addVertex(Vertex $vertex)
336336
*
337337
* @param Edge $edge instance of the new Edge
338338
* @return void
339-
* @private
339+
* @internal
340340
* @see Vertex::createEdge() instead!
341341
*/
342342
public function addEdge(Edge $edge)
@@ -350,7 +350,7 @@ public function addEdge(Edge $edge)
350350
* @param Edge $edge
351351
* @return void
352352
* @throws InvalidArgumentException if given edge does not exist (should not ever happen)
353-
* @private
353+
* @internal
354354
* @see Edge::destroy() instead!
355355
*/
356356
public function removeEdge(Edge $edge)
@@ -369,7 +369,7 @@ public function removeEdge(Edge $edge)
369369
* @param Vertex $vertex
370370
* @return void
371371
* @throws InvalidArgumentException if given vertex does not exist (should not ever happen)
372-
* @private
372+
* @internal
373373
* @see Vertex::destroy() instead!
374374
*/
375375
public function removeVertex(Vertex $vertex)

src/Set/DualAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Fhaculty\Graph\Set;
44

55
/**
6-
* DualAggregate provides access to both its Vertices and its Edges
6+
* A DualAggregate provides access to both its Vertices and its Edges
77
*
88
* This is the simple base interface for any Graph-like structure / data type
99
* which contains a Set of Edges and a Set of Vertices, such as the Graph class

src/Set/Edges.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getEdgeMatch($callbackCheck)
197197
* checks whethere there's an Edge that matches the given callback filter function
198198
*
199199
* @param callable $callbackCheck
200-
* @return boolean
200+
* @return bool
201201
* @see self::getEdgeMatch() to return the Edge instance that matches the given callback filter function
202202
* @uses self::getEdgeMatchOrNull()
203203
*/
@@ -209,7 +209,7 @@ public function hasEdgeMatch($callbackCheck)
209209
/**
210210
* get a new set of Edges that match the given callback filter function
211211
*
212-
* This only keeps Edge elements if the $callbackCheck returns a boolean
212+
* This only keeps Edge elements if the $callbackCheck returns a bool
213213
* true and filters out everything else.
214214
*
215215
* Edge index positions will be left unchanged.
@@ -229,7 +229,7 @@ public function getEdgesMatch($callbackCheck)
229229
* Edge index positions will be left unchanged.
230230
*
231231
* @param int $orderBy criterium to sort by. see self::ORDER_WEIGHT, etc.
232-
* @param boolean $desc whether to return biggest first (true) instead of smallest first (default:false)
232+
* @param bool $desc whether to return biggest first (true) instead of smallest first (default:false)
233233
* @return Edges a new Edges set ordered by the given $orderBy criterium
234234
* @throws InvalidArgumentException if criterium is unknown
235235
*/
@@ -273,7 +273,7 @@ public function getEdgesOrder($orderBy, $desc = false)
273273
* get first edge ordered by given criterium $orderBy
274274
*
275275
* @param int $orderBy criterium to sort by. see self::ORDER_WEIGHT, etc.
276-
* @param boolean $desc whether to return biggest (true) instead of smallest (default:false)
276+
* @param bool $desc whether to return biggest (true) instead of smallest (default:false)
277277
* @return Edge
278278
* @throws InvalidArgumentException if criterium is unknown
279279
* @throws UnderflowException if no edges exist
@@ -394,7 +394,7 @@ public function count()
394394
* A Set if empty if no single Edge instance is added. This is faster
395395
* than calling `count() === 0`.
396396
*
397-
* @return boolean
397+
* @return bool
398398
*/
399399
public function isEmpty()
400400
{

src/Set/EdgesAggregate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Fhaculty\Graph\Set;
44

55
/**
6-
* Basic interface for every class that provides access to its Set of Edges
6+
* A basic interface for every class that provides access to its Set of Edges
77
*/
88
interface EdgesAggregate
99
{

src/Set/Vertices.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getVertexId($id)
113113
* checks whether given vertex ID exists in this set of vertices
114114
*
115115
* @param int|string $id identifier of Vertex
116-
* @return boolean
116+
* @return bool
117117
* @uses self::hasVertexMatch()
118118
*/
119119
public function hasVertexId($id)
@@ -199,7 +199,7 @@ public function getVertexMatch($callbackCheck)
199199
* checks whether there's a Vertex that matches the given callback filter function
200200
*
201201
* @param callable $callbackCheck
202-
* @return boolean
202+
* @return bool
203203
* @see self::getVertexMatch() to return the Vertex instance that matches the given callback filter function
204204
* @uses self::getVertexMatchOrNull()
205205
*/
@@ -211,7 +211,7 @@ public function hasVertexMatch($callbackCheck)
211211
/**
212212
* get a new set of Vertices that match the given callback filter function
213213
*
214-
* This only keeps Vertex elements if the $callbackCheck returns a boolean
214+
* This only keeps Vertex elements if the $callbackCheck returns a bool
215215
* true and filters out everything else.
216216
*
217217
* Vertex index positions will be left unchanged, so if you call this method
@@ -233,7 +233,7 @@ public function getVerticesMatch($callbackCheck)
233233
* on a VerticesMap, it will also return a VerticesMap.
234234
*
235235
* @param int $orderBy criterium to sort by. see Vertex::ORDER_ID, etc.
236-
* @param boolean $desc whether to return biggest first (true) instead of smallest first (default:false)
236+
* @param bool $desc whether to return biggest first (true) instead of smallest first (default:false)
237237
* @return Vertices a new Vertices set ordered by the given $orderBy criterium
238238
* @throws InvalidArgumentException if criterium is unknown
239239
* @see self::getVertexOrder()
@@ -311,7 +311,7 @@ public function getVerticesIntersection($otherVertices)
311311
* get first vertex (optionally ordered by given criterium $by) from given array of vertices
312312
*
313313
* @param int $orderBy criterium to sort by. see Vertex::ORDER_ID, etc.
314-
* @param boolean $desc whether to return biggest (true) instead of smallest (default:false)
314+
* @param bool $desc whether to return biggest (true) instead of smallest (default:false)
315315
* @return Vertex
316316
* @throws InvalidArgumentException if criterium is unknown
317317
* @throws UnderflowException if no vertices exist
@@ -422,7 +422,7 @@ public function count()
422422
* A Set if empty if no single Vertex instance is added. This is faster
423423
* than calling `count() === 0`.
424424
*
425-
* @return boolean
425+
* @return bool
426426
*/
427427
public function isEmpty()
428428
{
@@ -432,7 +432,7 @@ public function isEmpty()
432432
/**
433433
* check whether this set contains any duplicate vertex instances
434434
*
435-
* @return boolean
435+
* @return bool
436436
* @uses self::getMap()
437437
*/
438438
public function hasDuplicates()

src/Vertex.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function createEdge(Vertex $vertex)
157157
*
158158
* @param Edge $edge
159159
* @return void
160-
* @private
160+
* @internal
161161
* @see self::createEdge() instead!
162162
*/
163163
public function addEdge(Edge $edge)
@@ -171,7 +171,7 @@ public function addEdge(Edge $edge)
171171
* @param Edge $edge
172172
* @return void
173173
* @throws InvalidArgumentException if given edge does not exist
174-
* @private
174+
* @internal
175175
* @see Edge::destroy() instead!
176176
*/
177177
public function removeEdge(Edge $edge)
@@ -187,7 +187,7 @@ public function removeEdge(Edge $edge)
187187
* check whether this vertex has a direct edge to given $vertex
188188
*
189189
* @param Vertex $vertex
190-
* @return boolean
190+
* @return bool
191191
* @uses Edge::hasVertexTarget()
192192
*/
193193
public function hasEdgeTo(Vertex $vertex)
@@ -203,7 +203,7 @@ public function hasEdgeTo(Vertex $vertex)
203203
* check whether the given vertex has a direct edge to THIS vertex
204204
*
205205
* @param Vertex $vertex
206-
* @return boolean
206+
* @return bool
207207
* @uses Vertex::hasEdgeTo()
208208
*/
209209
public function hasEdgeFrom(Vertex $vertex)

src/Walk.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function factoryFromEdges($edges, Vertex $startVertex)
4545
*
4646
* @param Vertices|Vertex[] $vertices
4747
* @param int|null $by
48-
* @param boolean $desc
48+
* @param bool $desc
4949
* @return Walk
5050
* @throws UnderflowException if no vertices were given
5151
* @see Edges::getEdgeOrder() for parameters $by and $desc
@@ -80,7 +80,7 @@ public static function factoryFromVertices($vertices, $by = null, $desc = false)
8080
* @param Vertex[] $predecessors map of vid => predecessor vertex instance
8181
* @param Vertex $vertex start vertex to search predecessors from
8282
* @param int|null $by
83-
* @param boolean $desc
83+
* @param bool $desc
8484
* @return Walk
8585
* @throws UnderflowException
8686
* @see Edges::getEdgeOrder() for parameters $by and $desc
@@ -130,7 +130,7 @@ public static function factoryCycleFromPredecessorMap(array $predecessors, Verte
130130
*
131131
* @param Vertex[]|Vertices $vertices
132132
* @param int|null $by
133-
* @param boolean $desc
133+
* @param bool $desc
134134
* @return Walk
135135
* @throws UnderflowException if no vertices were given
136136
* @see Edges::getEdgeOrder() for parameters $by and $desc
@@ -283,7 +283,7 @@ public function getAlternatingSequence()
283283
/**
284284
* check to make sure this walk is still valid (i.e. source graph still contains all vertices and edges)
285285
*
286-
* @return boolean
286+
* @return bool
287287
* @uses Walk::getGraph()
288288
* @uses Graph::getVertices()
289289
* @uses Graph::getEdges()

0 commit comments

Comments
 (0)