Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1.     function makeGraph(&$graph, $tree, $parent = null, $edge_label = "") {
  2.         $main = $graph->createVertex();
  3.         $main->setAttribute('graphviz.label', $tree->getAttributeName());
  4.         if($parent) {
  5.             $edge = $parent->createEdgeTo($main);
  6.             $edge->setAttribute('graphviz.label', $edge_label);
  7.         }
  8.         foreach ($tree->values as $key => $child) {
  9.             if ($child->getIsLeaf()) {
  10.                 $first_level_child = $graph->createVertex();                
  11.                 $edge = $main->createEdgeTo($first_level_child);
  12.                 $edge->setAttribute('graphviz.label', $key);
  13.                 if($child->getChild('result') == 'true') {
  14.                     $first_level_child->setAttribute('graphviz.color', 'green');
  15.                     $first_level_child->setAttribute('graphviz.label', $child->getAttributeName());
  16.                 } else {
  17.                     $first_level_child->setAttribute('graphviz.color', 'red');
  18.                     $first_level_child->setAttribute('graphviz.label', "nie ".$child->getAttributeName());
  19.                 }
  20.             } else {
  21.                 makeGraph($graph, $child, $main, $key);
  22.             }
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement