Subject: | Imagemap generation broken for fdp |
I'm using the new fdp layout and I get random layouts if I use clusters -- a big problem if you are generating imagemaps.
The problem seems to be that the subgraphs get added in a random order. The attached patch first adds all subgraphs to an array, then sorts them, _then_ adds them to the "dot" output.
--- GraphViz.pm.orig Tue Feb 15 10:43:59 2005
+++ GraphViz.pm Tue Feb 15 10:47:48 2005
@@ -1070,6 +1070,7 @@
}
}
+ my @dot_subgraphs=();
foreach my $clustername (sort keys %cluster_nodes) {
my $cluster = $clusters{$clustername};
my $attrs;
@@ -1094,12 +1095,21 @@
$attrs =~ s/,/;/go;
$attrs =~ s/\]$//o;
- $dot .= "\tsubgraph cluster_" . $self->_quote_name($name) . " {\n";
- $dot .= "\t\t$attrs;\n";
- $dot .= join "", map { "\t\t" . $self->{NODES}->{$_}->{_code} . _attributes($self->{NODES}->{$_}) . ";\n"; } (@{$cluster_nodes{$cluster}});
- $dot .= $clusters_edge{$cluster} if exists $clusters_edge{$cluster};
- $dot .= "\t}\n";
+ my $dot_subgraph .= "\tsubgraph cluster_" . $self->_quote_name($name) . " {\n";
+ $dot_subgraph .= "\t\t$attrs;\n";
+ $dot_subgraph .= join "", map { "\t\t" . $self->{NODES}->{$_}->{_code} . _attributes($self->{NODES}->{$_}) . ";\n"; } (@{$cluster_nodes{$cluster}});
+ $dot_subgraph .= $clusters_edge{$cluster} if exists $clusters_edge{$cluster};
+ $dot_subgraph .= "\t}\n";
+
+ push (@dot_subgraphs, $dot_subgraph);
}
+
+# order the subgraph additions -- otherwise fdp returns diagrams
+# that vary each time
+ foreach my $dot_subgraph (sort @dot_subgraphs)
+ {
+ $dot .= $dot_subgraph;
+ }
# Deal with ranks
my %ranks;