Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 16, 2018
1 parent e136a4d commit b090550
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It also provides [4 trees traversals algorithm](https://en.wikipedia.org/wiki/Tr
* Pre order
* Breadth first

And it provides Exporters and Importers for:
And it provides exporters and importers:
* Graph: Export a tree into a graph using the [graphp/graphp](https://github.com/graphp/graph) library.
* Text: Export a tree into a simple string.

Expand Down Expand Up @@ -55,22 +55,29 @@ declare(strict_types = 1);
use Graphp\GraphViz\GraphViz;
use drupol\phptree\Exporter\Graph;
use drupol\phptree\Node\ValueNode;
use drupol\phptree\Exporter\Text;

include './vendor/autoload.php';

// Create the root node.
$tree = new ValueNode('root', 2);

$nodes = [];
foreach (\range('A', 'Z') as $v) {
$nodes[] = new ValueNode($v);
}

// Add children to the root node.
$tree->add(...$nodes);

// Export to an image.
$graphViz = new GraphViz();
$exporter = new Graph();
$graphExporter = new Graph();
$graphViz->display($graphExporter->export($tree));

$graphViz->display($exporter->export($tree));
// Export to text.
$textExporter = new Text();
echo $textExporter->export($tree); // [root [A [C [G [O] [P]] [H [Q] [R]]] [D [I [S] [T]] [J [U] [V]]]] [B [E [K [W] [X]] [L [Y] [Z]]] [F [M] [N]]]]⏎
```

## Code quality, tests and benchmarks
Expand Down

0 comments on commit b090550

Please sign in to comment.