2017 © Pedro Peláez
 

library graph

The Hoa\Graph library.

image

hoa/graph

The Hoa\Graph library.

  • Thursday, August 3, 2017
  • by Hoa
  • Repository
  • 11 Watchers
  • 7 Stars
  • 364 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

Hoa , (*1)


Build status Code coverage Packagist License , (*2)

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds. , (*3)

Hoa\Graph

Help on IRC Help on Gitter Documentation Board, (*4)

This library allows to create and manipulate directed graphs, a common data structure. A directed graph is basically a set of vertices (aka nodes) and directed edges between vertices., (*5)

Learn more., (*6)

Installation

With Composer, to include this library into your dependencies, you need to require hoa/graph:, (*7)

$ composer require hoa/graph '~1.0'

For more installation procedures, please read the Source page., (*8)

Testing

Before running the test suites, the development dependencies must be installed:, (*9)

$ composer install

Then, to run all the test suites:, (*10)

$ vendor/bin/hoa test:run

For more information, please read the contributor guide., (*11)

Quick usage

As a quick overview, we propose to see how to create a simple directed graph in memory and dump the result as a DOT script in order to visualize it in SVG. The graph implementation will use the adjacency list structure. Thus:, (*12)

// Create the graph instance.
// By default, loops are not allowed and we would like loops for this example,
// so we enable them.
$graph = new Hoa\Graph\AdjacencyList(Hoa\Graph::ALLOW_LOOP);

// Create 4 vertices (aka nodes).
$n1 = new Hoa\Graph\SimpleNode('n1');
$n2 = new Hoa\Graph\SimpleNode('n2');
$n3 = new Hoa\Graph\SimpleNode('n3');
$n4 = new Hoa\Graph\SimpleNode('n4');

// Create edges (aka links) between them.
$graph->addNode($n1);
$graph->addNode($n2, [$n1]); // n2 has parent n1.
$graph->addNode($n3, [$n1, $n2, $n3]); // n3 has parents n1, n2 and n3.
$graph->addNode($n4, [$n3]); // n4 has parent n3.
$graph->addNode($n2, [$n4]); // Add parent n4 to n2.

The directed graph is created in memory. Now, let's dump into the DOT language:, (*13)

echo $graph;

/**
 * Will output:
 *     digraph {
 *         n1;
 *         n2;
 *         n3;
 *         n4;
 *         n1 -> n2;
 *         n1 -> n3;
 *         n2 -> n3;
 *         n3 -> n3;
 *         n3 -> n4;
 *         n4 -> n2;
 *     }
 */

Then, to compile this DOT script into an SVG document, we will use dot(1):, (*14)

$ dot -Tsvg -oresult.svg <( echo 'digraph { … }'; )

And the result should look like the following image:, (*15)

result.svg, (*16)

We can see that n1 is the parent of n2 and n3. n2 is the parent of n3. n3 is parent of n4 and also or iself. And finally, n4 is the parent of n2., (*17)

Our directed graph is created. Depending of the node, we can add more information on it. The SimpleNode class has been used. It extends the Hoa\Graph\Node interface., (*18)

Documentation

The hack book of Hoa\Graph contains detailed information about how to use this library and how it works., (*19)

To generate the documentation locally, execute the following commands:, (*20)

$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open

More documentation can be found on the project's website: hoa-project.net., (*21)

Getting help

There are mainly two ways to get help:, (*22)

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know., (*23)

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details., (*24)

The Versions

03/08 2017

dev-master

9999999-dev https://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library graph node automata

13/01 2017

1.17.01.13

1.17.01.13 https://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library graph node automata

06/04 2016

1.16.04.06

1.16.04.06 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library graph node automata

05/04 2016

0.16.04.05

0.16.04.05 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library graph node automata

22/03 2016

0.16.03.22

0.16.03.22 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library graph node automata

11/01 2016

0.16.01.11

0.16.01.11 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

08/09 2015

0.15.09.08

0.15.09.08 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

28/07 2015

0.15.07.28

0.15.07.28 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

29/05 2015

0.15.05.29

0.15.05.29 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

13/04 2015

0.15.04.13

0.15.04.13 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

20/02 2015

0.15.02.20

0.15.02.20 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

09/12 2014

0.14.12.10

0.14.12.10 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

23/09 2014

0.14.09.23

0.14.09.23 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

17/09 2014

0.14.09.17

0.14.09.17 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata

16/09 2014

0.14.09.16

0.14.09.16 http://hoa-project.net/

The Hoa\Graph library.

  Sources   Download

BSD-3-Clause

The Requires

 

library graph node automata