Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeGraph(&$graph, $tree, $parent = null, $edge_label = "") {
- $main = $graph->createVertex();
- $main->setAttribute('graphviz.label', $tree->getAttributeName());
- if($parent) {
- $edge = $parent->createEdgeTo($main);
- $edge->setAttribute('graphviz.label', $edge_label);
- }
- foreach ($tree->values as $key => $child) {
- if ($child->getIsLeaf()) {
- $first_level_child = $graph->createVertex();
- $edge = $main->createEdgeTo($first_level_child);
- $edge->setAttribute('graphviz.label', $key);
- if($child->getChild('result') == 'true') {
- $first_level_child->setAttribute('graphviz.color', 'green');
- $first_level_child->setAttribute('graphviz.label', $child->getAttributeName());
- } else {
- $first_level_child->setAttribute('graphviz.color', 'red');
- $first_level_child->setAttribute('graphviz.label', "nie ".$child->getAttributeName());
- }
- } else {
- makeGraph($graph, $child, $main, $key);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement