Skip to content

Commit d71bcb1

Browse files
committed
Optimize the Graph exporter.
1 parent 6fd1ed1 commit d71bcb1

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Exporter/Graph.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,12 @@ public function export(NodeInterface $node): OriginalGraph
3030

3131
foreach ($node->all() as $node_visited) {
3232
/** @var int $vertexId */
33-
$vertexId = $this->createVertexId($node_visited);
34-
$this->createVertex($node_visited);
33+
$vertexFrom = $this->createVertex($node_visited);
3534

36-
if (null === $parent = $node_visited->getParent()) {
37-
continue;
35+
foreach ($node_visited->children() as $child) {
36+
$vertexTo = $this->createVertex($child);
37+
$vertexFrom->createEdgeTo($vertexTo);
3838
}
39-
40-
/** @var int $hash_parent */
41-
$hash_parent = $this->createVertexId($parent);
42-
$this->createVertex($parent);
43-
44-
$this->getGraph()->getVertex($hash_parent)->createEdgeTo($this->getGraph()->getVertex($vertexId));
4539
}
4640

4741
return $this->getGraph();

0 commit comments

Comments
 (0)