1--TEST-- 2Unit test for graph with edges on clusters 3--FILE-- 4<?php 5 6/** 7 * Test 17: "Graph with edges on clusters" 8 * 9 * Graph definition taken from GraphViz documentation 10 * 11 * @category Image 12 * @package Image_GraphViz 13 * @author Philippe Jausions <jausions@php.net> 14 */ 15require_once 'Image/GraphViz.php'; 16 17$graph = new Image_GraphViz(true, array('compound' => true), 'G', false); 18 19$graph->addCluster('cluster0', ''); 20$graph->addNode('a', null, 'cluster0'); 21$graph->addNode('b', null, 'cluster0'); 22$graph->addNode('c', null, 'cluster0'); 23$graph->addNode('d', null, 'cluster0'); 24 25$graph->addEdge(array('a' => 'b')); 26$graph->addEdge(array('a' => 'c')); 27$graph->addEdge(array('b' => 'd')); 28$graph->addEdge(array('c' => 'd')); 29 30$graph->addCluster('cluster1', ''); 31$graph->addNode('e', null, 'cluster1'); 32$graph->addNode('f', null, 'cluster1'); 33$graph->addNode('g', null, 'cluster1'); 34 35$graph->addEdge(array('e' => 'g')); 36$graph->addEdge(array('e' => 'f')); 37 38$graph->addEdge(array('b' => 'f'), array('lhead' => 'cluster1')); 39$graph->addEdge(array('d' => 'e')); 40$graph->addEdge(array('c' => 'g'), array('ltail' => 'cluster0', 41 'lhead' => 'cluster1')); 42$graph->addEdge(array('c' => 'e'), array('ltail' => 'cluster0')); 43 44$graph->addEdge(array('d' => 'h')); 45 46echo $graph->parse(); 47 48?> 49--EXPECT-- 50digraph G { 51 compound=true; 52 subgraph cluster0 { 53 a; 54 b; 55 c; 56 d; 57 } 58 subgraph cluster1 { 59 e; 60 f; 61 g; 62 } 63 a -> b; 64 a -> c; 65 b -> d; 66 b -> f [ lhead=cluster1 ]; 67 c -> d; 68 c -> g [ ltail=cluster0,lhead=cluster1 ]; 69 c -> e [ ltail=cluster0 ]; 70 e -> g; 71 e -> f; 72 d -> e; 73 d -> h; 74}