Skip to content

Commit b090550

Browse files
committed
Update README.
1 parent e136a4d commit b090550

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ It also provides [4 trees traversals algorithm](https://en.wikipedia.org/wiki/Tr
2424
* Pre order
2525
* Breadth first
2626

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

@@ -55,22 +55,29 @@ declare(strict_types = 1);
5555
use Graphp\GraphViz\GraphViz;
5656
use drupol\phptree\Exporter\Graph;
5757
use drupol\phptree\Node\ValueNode;
58+
use drupol\phptree\Exporter\Text;
5859

5960
include './vendor/autoload.php';
6061

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

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

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

73+
// Export to an image.
7074
$graphViz = new GraphViz();
71-
$exporter = new Graph();
75+
$graphExporter = new Graph();
76+
$graphViz->display($graphExporter->export($tree));
7277

73-
$graphViz->display($exporter->export($tree));
78+
// Export to text.
79+
$textExporter = new Text();
80+
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]]]]⏎
7481
```
7582

7683
## Code quality, tests and benchmarks

0 commit comments

Comments
 (0)