gv.php

RESOLVED

$g2 = gv::graph($g, 'subgraph cluster'); ->> $g2 = gv::graph($g, 'cluster0');
" If the name of the subgraph begins with cluster, Graphviz notes the subgraph as a special cluster subgraph."

Using gv.php, i need create a subgroup cluster http://www.graphviz.org/pdf/gv.3php.pdf . I m using the code

<?php include('libgv-php5/gv.php');
$g = gv::digraph('my first graph');
$g2 = gv::graph($g, 'subgraph cluster');
$node1 = gv::node($g, 'node1');
$node2 = gv::node($g, 'node2');
$node3 = gv::node($g2, 'node3');
$node4 = gv::node($g2, 'node4');
gv::edge($node1, $node2);
gv::edge($node2, $node3);
gv::edge($node3, $node4);
gv::edge($node3, $node1);
gv::layout($g, 'dot');
gv::render($g, 'png', 'graph.png');
gv::rm($g);
echo ' < i m g  s r c = " g r a p h . p n g " >'; ?>

but the cluster is not create. Does anyone have an idea?

AttachmentSize
screenshot1.png16.14 KB

Solved

" If the name of the subgraph begins with cluster, Graphviz notes the subgraph as a special cluster subgraph."

sample 

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

  $g = gv::digraph('G'); //line 1
  $N = gv::protonode($g); // line 3
  
  $cluster0 = gv::graph($g, 'cluster0'); // line 2
  gv::setv($N, "style", "filled"); // line 3
  gv::setv($N, "color", "white"); // line 3
  gv::setv($cluster0, "style", "filled"); // line 4
  gv::setv($cluster0, "color", "lightgrey"); // line 5
  gv::edge($cluster0, 'a0', 'a1'); //line 6
  gv::edge($cluster0, 'a1', 'a2'); //line 6
  gv::edge($cluster0, 'a2', 'a3'); //line 6
  gv::setv($cluster0, "label", "process #1"); // line 7

  $cluster1 = gv::graph($g, 'cluster1'); // line 10
  gv::setv($N, "style", "solid");
  gv::setv($N, "color", "black");
  gv::edge($cluster1, 'b0', 'b1'); //line 12
  gv::edge($cluster1, 'b1', 'b2'); //line 12
  gv::edge($cluster1, 'b2', 'b3'); //line 12
  gv::setv($cluster1, "label", "process #2"); // line 13
  gv::setv($cluster1, "color", "blue"); // line 14  

  $node_start = gv::node($g, 'start');
  gv::setv($node_start, "shape", "Mdiamond");
  $node_end = gv::node($g, 'end');
  gv::setv($node_end, "shape", "Msquare");

  gv::edge($g, 'start', 'a0'); //line 16
  gv::edge($g, 'start', 'b0'); //line 17
  gv::edge($g, 'a1', 'b3'); //line 18
  gv::edge($g, 'b2', 'a3'); //line 19
  gv::edge($g, 'a0', 'a3'); //line 20
  gv::edge($g, 'a3', 'end'); //line 21
  gv::edge($g, 'b3', 'end'); //line 22

  gv::layout($g, 'dot');

  gv::render($g, 'png', 'graph1.png');
  gv::rm($g);

  echo '<img src="graph1.png">';
?>

 

Recent comments