Skip Menu |

This queue is for tickets about the GraphViz CPAN distribution.

Report information
The Basics
Id: 42969
Status: resolved
Priority: 0/
Queue: GraphViz

People
Owner: Nobody in particular
Requestors: Philip [...] kime.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Patch against 2.04 to allow more Graphiz options
Date: Mon, 02 Feb 2009 16:50:18 +0100
To: bug-GraphViz [...] rt.cpan.org
From: Philip Kime <philip [...] kime.org.uk>
Attached is a patch against 2.04 which adds the following options: * strict (allows strict graphs to be created) * stylesheet (allows SVG stylesheet to be specified) * as_pdf (allows pdf output) The documentation is included in the POD format and I have tested these additions a great deal. They are simply just passing through options to dot etc. PK -- Dr P Kime

Message body is not shown because sender requested not to inline it.

Was a small bug in the last patch - this one really works ...
--- ../../Desktop/GraphViz.pm 2009-02-03 15:09:21.675484000 +0100 +++ ../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};
This issue is fixed in GraphViz2 V 1.00. There're won't be any further development on GraphViz.