gv.php 2

I want to replicate the example from http://www.graphviz.org/pdf/dotguide.pdf page 22
Attached image result, but i can't replicate 
line 16: node0:f0 -> node1:n;
line 17: node0:f1 -> node2:n;
line 18: node0:f2 -> node3:n;
line 19: node0:f5 -> node4:n;
line 20: node0:f6 -> node5:n;
line 21: node2:p -> node6:n;
line 22: node4:p -> node7:n;

any idea?

<?php
  //http://www.graphviz.org/pdf/dotguide.pdf page 22
  include('libgv-php5/gv.php');

  $g = gv::digraph('G'); // line 1
  gv::setv($g, "nodesep", "0.05"); // line 2
  gv::setv($g, "rankdir", "LR"); // line 3
  $N = gv::protonode($g);
  gv::setv($N, "shape", "record"); //line 4
  gv::setv($N, "width", "0.1"); //line 4
  gv::setv($N, "height", "0.1"); //line 4

  $node0 = gv::node($g, 'node0'); //line 6
  gv::setv($node0, "label", "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | ");  //line 6
  gv::setv($node0, "height", "2.5"); //line 6
  gv::setv($N, "width", "1.5"); //line 7
  
  $node1 = gv::node($g, 'node1'); //line 8
  gv::setv($node1, "label", '{<n> n14 | 719 |<p> }');  //line 8    
  $node2 = gv::node($g, 'node2'); //line 9
  gv::setv($node2, "label", "{<n> a1 | 805 |<p> }");  //line 9    
  $node3 = gv::node($g, 'node3'); //line 10
  gv::setv($node3, "label", "{<n> i9 | 718 |<p> }");  //line 10   
  $node4 = gv::node($g, 'node4'); //line 11
  gv::setv($node4, "label", "{<n> e5 | 989 |<p> }");  //line 11    
  $node5 = gv::node($g, 'node5'); //line 12
  gv::setv($node5, "label", "{<n> t20 | 959 |<p> }");  //line 12    
  $node6 = gv::node($g, 'node6'); //line 13
  gv::setv($node6, "label", "{<n> o15 | 794 |<p> }");  //line 13    
  $node7 = gv::node($g, 'node7'); //line 14
  gv::setv($node7, "label", "{<n> s19 | 659 |<p> }");  //line 14    

  gv::edge($node0, $node1); //line 16
  gv::edge($node0, $node2); //line 17
  gv::edge($node0, $node3); //line 18
  gv::edge($node0, $node4); //line 19
  gv::edge($node0, $node5); //line 20
  gv::edge($node2, $node6); //line 21
  gv::edge($node4, $node7); //line 22

  gv::layout($g, 'dot');
  gv::render($g, 'png', 'graph.png');
  
  echo '<img src="graph.png">';
  gv::rm($g);  
?>

 

AttachmentSize
screenshot1.png14.02 KB

Recent comments