All Projects → hoaproject → Graph

hoaproject / Graph

Licence: other
The Hoa\Graph library.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Graph

Stream
The Hoa\Stream library.
Stars: ✭ 313 (+2135.71%)
Mutual labels:  hoa
Ustring
The Hoa\Ustring library.
Stars: ✭ 403 (+2778.57%)
Mutual labels:  hoa
Eventsource
The Hoa\Eventsource library.
Stars: ✭ 99 (+607.14%)
Mutual labels:  hoa
Consistency
The Hoa\Consistency library.
Stars: ✭ 317 (+2164.29%)
Mutual labels:  hoa
Console
The Hoa\Console library.
Stars: ✭ 354 (+2428.57%)
Mutual labels:  hoa
Compiler
The Hoa\Compiler library.
Stars: ✭ 458 (+3171.43%)
Mutual labels:  hoa
Protocol
The Hoa\Protocol library.
Stars: ✭ 308 (+2100%)
Mutual labels:  hoa
Sparta
A collection of spatial audio related VST plug-ins (loudspeaker/binaural panners, Ambisonics encoders/decoders/visualisers, etc.)
Stars: ✭ 165 (+1078.57%)
Mutual labels:  hoa
Math
The Hoa\Math library.
Stars: ✭ 370 (+2542.86%)
Mutual labels:  hoa
Kitab
Kitab is the ideal companion for Documentation-Driven Quality: Render and Test your documentation.
Stars: ✭ 79 (+464.29%)
Mutual labels:  hoa
Event
The Hoa\Event library
Stars: ✭ 319 (+2178.57%)
Mutual labels:  hoa
Iterator
The Hoa\Iterator library.
Stars: ✭ 333 (+2278.57%)
Mutual labels:  hoa
Ruler
The Hoa\Ruler library.
Stars: ✭ 612 (+4271.43%)
Mutual labels:  hoa
Exception
The Hoa\Exception library.
Stars: ✭ 316 (+2157.14%)
Mutual labels:  hoa
Mime
The Hoa\Mime library.
Stars: ✭ 100 (+614.29%)
Mutual labels:  hoa
Regex
The Hoa\Regex library.
Stars: ✭ 308 (+2100%)
Mutual labels:  hoa
Websocket
The Hoa\Websocket library.
Stars: ✭ 421 (+2907.14%)
Mutual labels:  hoa
Cinder-Hoa
Higher Order Ambisonics Block for libCinder
Stars: ✭ 12 (-14.29%)
Mutual labels:  hoa
Central
Hoa is a modular, extensible, and structured set of PHP libraries.
Stars: ✭ 105 (+650%)
Mutual labels:  hoa
Devtools
The Hoa\Devtools library.
Stars: ✭ 5 (-64.29%)
Mutual labels:  hoa

Hoa


Build status Code coverage Packagist License

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

Hoa\Graph

Help on IRC Help on Gitter Documentation Board

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.

Learn more.

Installation

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

$ composer require hoa/graph '~1.0'

For more installation procedures, please read the Source page.

Testing

Before running the test suites, the development dependencies must be installed:

$ composer install

Then, to run all the test suites:

$ vendor/bin/hoa test:run

For more information, please read the contributor guide.

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:

// 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:

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):

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

And the result should look like the following image:

result.svg

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.

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.

Documentation

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

To generate the documentation locally, execute the following commands:

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

More documentation can be found on the project's website: hoa-project.net.

Getting help

There are mainly two ways to get help:

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].