Package: libgraph-writer-graphviz-perl
Version: 0.11-1

IMO it should be possible to specify more edge attributes.  For
example, "label".

The attached patch does this for the attributes "style", "label",
"color" in roughly the same way as is done for node attributes.

(To be honest, it would be better to have some general way to specify
arbitrary attributes for the dot output, rather than insisting on
mapping the dot attribute namespace directly but piecemeal into the
Graph.pm.  But I haven't implemented that here.)

There is a possible compatibility implication for this patch: if
someone sets these attributes on edges and uses
Graph::Writer::GraphViz then there will be a chane in behaviour.
(Perhaps a desired behaviour which didn't turn up but which now would
be surprising.)  But I think this risk is probably tolerable.

Thanks,
Ian.

>From c4867b03b8669aed64b0d943bdf2d3f7b7427cc1 Mon Sep 17 00:00:00 2001
From: Ian Jackson <ijack...@chiark.greenend.org.uk>
Date: Wed, 5 Feb 2014 21:59:31 +0000
Subject: [PATCH] Honour edge attributes `style', `label', `color': pass them
 to graphviz.

---
 debian/changelog             |    7 +++++++
 lib/Graph/Writer/GraphViz.pm |    6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index d6a3342..8b9bd5f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+libgraph-writer-graphviz-perl (0.11-2) UNRELEASED; urgency=low
+
+  * Honour edge attributes `style', `label', `color': pass them
+    to graphviz.
+
+ -- Ian Jackson <ijack...@chiark.greenend.org.uk>  Wed, 05 Feb 2014 21:59:24 
+0000
+
 libgraph-writer-graphviz-perl (0.11-1) unstable; urgency=low
 
   [ Ansgar Burchardt ]
diff --git a/lib/Graph/Writer/GraphViz.pm b/lib/Graph/Writer/GraphViz.pm
index 8302354..bbdcb22 100644
--- a/lib/Graph/Writer/GraphViz.pm
+++ b/lib/Graph/Writer/GraphViz.pm
@@ -81,6 +81,12 @@ sub add_edges {
            my $w = $g->get_edge_weight($a,$b);
            $param{weight} = $w;
        }
+        for my $attr (qw/style label color/) {
+            if($g->has_edge_attribute($a,$b,$attr)) {
+                my $w = $g->get_edge_attribute($a,$b,$attr);
+                $param{$attr} = $w;
+            }
+        }
        $r->add_edge($a,$b,%param);
     }
 }
-- 
1.7.10.4

Reply via email to