Package: libgraphviz-perl
Version: 2.04-1
Severity: minor
Tags: patch
kthxbye
Hi there,
find attached four dpatches. They basically bring ligraphviz-perl a little
closer to the feature level of graphviz. The first patch is taken from the
upstream bug tracker: https://rt.cpan.org/Public/Bug/Display.html?id=42969
The other patches are written by me and rather trivial. They add nodesep and
ranksep, splines, label and labelloc support.
Kind regards,
Lee
#! /bin/sh /usr/share/dpatch/dpatch-run
## 01-allow_strict_svg_stylesheet_pdf.dpatch by <rand...@ishikawa>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Allow strict graphs, SVG stylesheets and PDF output.
@DPATCH@
--- ./lib/GraphViz.pm 2009-02-03 15:09:21.675484000 +0100
+++ ./lib/GraphViz.pm 2009-02-03 15:07:36.223708800 +0100
@@ -122,12 +122,14 @@
my $g = GraphViz->new();
my $g = GraphViz->new(directed => 0);
my $g = GraphViz->new(layout => 'neato', ratio => 'compress');
+ my $g = GraphViz->new(styesheet => "svg.css");
+ my $g = GraphViz->new(strict => 1);
my $g = GraphViz->new(rankdir => 1);
my $g = GraphViz->new(width => 8.5, height => 11);
my $g = GraphViz->new(width => 30, height => 20,
pagewidth => 8.5, pageheight => 11);
-The most two important attributes are 'layout' and 'directed'.
+The most important attributes are 'layout', directed' and 'strict'.
=over
@@ -160,12 +162,22 @@
=back
+=item strict
+
+The 'strict' attribute, which defaults to 0 (false) specifies
+a strict graph where multiple edges between nodes are collapsed
+into a single edge.
+
=item directed
The 'directed' attribute, which defaults to 1 (true) specifies
directed (edges have arrows) graphs. Setting this to zero produces
undirected graphs (edges do not have arrows).
+=item stylesheet
+
+'stylesheet' is a path to include in a stylesheet tag in output such as SVG.
+
=item rankdir
Another attribute 'rankdir' controls the direction the nodes are linked
@@ -351,6 +363,14 @@
$self->{NODELIST} = [];
$self->{EDGES} = [];
+ if ( exists $config->{strict} ) {
+ $self->{STRICT} = 1;
+ }
+
+ if ( exists $config->{stylesheet} ) {
+ $self->{STYLESHEET} = "\"$config->{stylesheet}\"";
+ }
+
if ( exists $config->{directed} ) {
$self->{DIRECTED} = $config->{directed};
} else {
@@ -828,6 +848,12 @@
Paris -> London [pos="s,38,98 39,92 40,78 40,60 39,45"];
}
+=item as_pdf
+
+Returns a string which contains a layed-out PDF-format file.
+
+ print $g->as_pdf;
+
=item as_ps
Returns a string which contains a layed-out PostScript-format file.
@@ -990,7 +1016,7 @@
}
if ( $name
- =~
/^as_(ps|hpgl|pcl|mif|pic|gd|gd2|gif|jpeg|png|wbmp|cmapx?|ismap|imap|vrml|vtx|mp|fig|svgz?|dot|canon|plain)$/
+ =~
/^as_(pdf|ps|hpgl|pcl|mif|pic|gd|gd2|gif|jpeg|png|wbmp|cmapx?|ismap|imap|vrml|vtx|mp|fig|svgz?|dot|canon|plain)$/
)
{
my $data = $self->_as_generic( '-T' . $1, $self->_as_debug, $output );
@@ -1010,14 +1036,15 @@
my $self = shift;
my $dot;
-
+
+ my $strict_graph = $self->{STRICT} ? 'strict ' : '';
my $graph_type = $self->{DIRECTED} ? 'digraph' : 'graph';
- $dot .= $graph_type . " " . $self->{NAME} . " {\n";
+ $dot .= $strict_graph . $graph_type . " " . $self->{NAME} . " {\n";
# the direction of the graph
$dot .= "\trankdir=LR;\n" if $self->{RANK_DIR};
-
+
# the size of the graph
$dot .= "\tsize=\"" . $self->{WIDTH} . "," . $self->{HEIGHT} . "\";\n"
if $self->{WIDTH} && $self->{HEIGHT};
@@ -1035,6 +1062,9 @@
# epsilon
$dot .= "\tepsilon=" . $self->{EPSILON} . ";\n" if $self->{EPSILON};
+
+ # stylesheet for SVG output
+ $dot .= "\tstylesheet=" . $self->{STYLESHEET} . ";\n" if
$self->{STYLESHEET};
# random start
$dot .= "\tstart=rand;\n" if $self->{RANDOM_START};
#! /bin/sh /usr/share/dpatch/dpatch-run
## add_nodesep_ranksep.patch.dpatch by <rand...@ishikawa>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add support for the nodesep and ranksep attributes
@DPATCH@
--- ./lib/GraphViz.pm 2010-08-31 23:37:04.783405945 +0200
+++ ./lib/GraphViz.pm 2010-08-31 23:52:18.073400357 +0200
@@ -377,6 +377,14 @@
$self->{DIRECTED} = 1; # default to directed
}
+ if ( exists $config->{nodesep} ) {
+ $self->{NODESEP} = $config->{nodesep};
+ }
+
+ if ( exists $config->{ranksep} ) {
+ $self->{RANKSEP} = $config->{ranksep};
+ }
+
if ( exists $config->{layout} ) {
$self->{LAYOUT} = $config->{layout};
} else {
@@ -1057,6 +1065,12 @@
# Ratio setting
$dot .= "\tratio=\"" . $self->{RATIO} . "\";\n";
+ # nodesep setting
+ $dot .= "\tnodesep=\"" . $self->{NODESEP} . "\";\n" if $self->{NODESEP};
+
+ # ranksep setting
+ $dot .= "\tranksep=\"" . $self->{RANKSEP} . "\";\n" if $self->{RANKSEP};
+
# edge merging
$dot .= "\tconcentrate=true;\n" if $self->{CONCENTRATE};
#! /bin/sh /usr/share/dpatch/dpatch-run
## 03-add_splines.patch.dpatch by <rand...@ishikawa>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add support for the splines attribute
@DPATCH@
--- ./lib/GraphViz.pm 2010-09-01 00:38:20.603393305 +0200
+++ ./lib/GraphViz.pm 2010-09-01 00:37:40.470166476 +0200
@@ -401,6 +401,8 @@
$self->{BGCOLOR} = $config->{bgcolor};
}
+ $self->{SPLINES} = $config->{splines} if (exists $config->{splines});
+
$self->{RANK_DIR} = $config->{rankdir} if ( exists $config->{rankdir} );
$self->{WIDTH} = $config->{width} if ( exists $config->{width} );
@@ -1050,6 +1052,9 @@
$dot .= $strict_graph . $graph_type . " " . $self->{NAME} . " {\n";
+ # spline-edge
+ $dot .= "\tsplines=\"" . $self->{SPLINES} . "\";\n" if $self->{SPLINES};
+
# the direction of the graph
$dot .= "\trankdir=LR;\n" if $self->{RANK_DIR};
#! /bin/sh /usr/share/dpatch/dpatch-run
## 04-add_label_labelloc.patch.dpatch by <rand...@ishikawa>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add label and labelloc attributes
@DPATCH@
--- ./lib/GraphViz.pm 2010-09-01 00:49:27.205892599 +0200
+++ ./lib/GraphViz.pm 2010-09-01 01:02:01.875924826 +0200
@@ -401,6 +401,9 @@
$self->{BGCOLOR} = $config->{bgcolor};
}
+ $self->{LABEL} = $config->{label} if (exists $config->{label});
+ $self->{LABELLOC} = $config->{labelloc} if (exists $config->{labelloc});
+
$self->{SPLINES} = $config->{splines} if (exists $config->{splines});
$self->{RANK_DIR} = $config->{rankdir} if ( exists $config->{rankdir} );
@@ -1052,6 +1055,10 @@
$dot .= $strict_graph . $graph_type . " " . $self->{NAME} . " {\n";
+ # label & labelloc
+ $dot .= "\tlabel=\"" . $self->{LABEL} . "\";\n" if $self->{LABEL};
+ $dot .= "\tlabelloc=\"" . $self->{LABELLOC} . "\";\n" if $self->{LABELLOC};
+
# spline-edge
$dot .= "\tsplines=true;\n" if $self->{SPLINES};