Yes it is possible. See cluster2.pl example in GraphViz CPAN module.
#!/usr/bin/perl
use strict;
use warnings;
use GraphViz;
my $g = GraphViz->new();
my @default_attrs = (
fontsize => '8',
fontname => 'arial',
);
my $eurocluster = {name=>'Europe',
style=>'filled',
fillcolor=>'lightgray',
fontname=>'arial',
fontsize=>'12',
};
$g->add_node('London', cluster=>$eurocluster, @default_attrs);
$g->add_node('Paris', cluster=>$eurocluster, @default_attrs);
$g->add_node('New York', @default_attrs);
$g->add_edge('London' => 'Paris', @default_attrs);
$g->add_edge('London' => 'New York', label => 'Far', @default_attrs);
$g->add_edge('Paris' => 'London', @default_attrs);
$g->as_gif("nodes.gif");
$g->as_dot("nodes.dot");
That is the result nodes.dot files
digraph test {
graph [ratio=fill];
node [label="\N"];
graph [bb="0,0,150,174"];
subgraph cluster_Europe {
graph [fillcolor=lightgray,
fontname=arial,
fontsize=12,
label=Europe,
style=filled,
bb="8,8,78,166"];
London [label=London, fontname=arial, fontsize=8, pos="43,118"
+, width="0.75", height="0.5"];
Paris [label=Paris, fontname=arial, fontsize=8, pos="43,34", w
+idth="0.75", height="0.5"];
London -> Paris [fontname=arial, fontsize=8, pos="e,37.367,51.
+789 37.364,100.19 36.203,89.049 35.949,74.471 36.604,61.831"];
Paris -> London [fontname=arial, fontsize=8, pos="e,48.636,100
+.19 48.633,51.789 49.796,62.92 50.051,77.497 49.398,90.14"];
}
"New York" [label="New York", fontname=arial, fontsize=8, pos="119
+,34", width="0.86111", height="0.5"];
London -> "New York" [fontname=arial, fontsize=8, label=Far, pos="
+e,104.51,50.015 57.295,102.2 68.687,89.609 84.811,71.787 97.72,57.52"
+, lp="91.5,76"];
}
|