PHP code example of innmind / graphviz
1. Go to this page and download the library: Download innmind/graphviz library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
innmind / graphviz example snippets
use Innmind\Graphviz\{
Layout\Dot,
Graph,
Node,
Node\Shape,
};
use Innmind\Url\Url;
use Innmind\Colour\Colour;
use Innmind\OperatingSystem\Factory;
use Innmind\Server\Control\Server\Command;
$dot = Dot::of();
$clusterOne = Graph::directed('one')
->target(Url::of('http://example.com'))
->displayAs('One')
->fillWithColor(Colour::blue->toRGBA())
->add($one = Node::named('one'));
$clusterTwo = Graph::directed('two')
->fillWithColor(Colour::red->toRGBA())
->add($two = Node::named('two'));
$clusterThree = Graph::directed('three')
->add($three = Node::named('three'));
$root = Node::named('root')
->shaped(Shape::house())
->linkedTo($one->name())
->linkedTo($two->name());
$graph = Graph::directed()
->add($root)
->add($one->linkedTo($three->name()))
->add($two->linkedTo($three->name()))
->cluster($clusterOne)
->cluster($clusterTwo)
->cluster($clusterThree);
$output = $dot($graph);
Factory::build()
->control()
->processes()
->execute(
Command::foreground('dot')
->withShortOption('Tsvg')
->withShortOption('o', 'graph.svg')
->withInput($output),
)
->wait();