This queue is for tickets about the Graph-Easy CPAN distribution.

Report information
The Basics
Id:
46992
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
nephtys62 [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



Subject: GraphML: end tag of nodes before definition of their attributes
Hi, I noticed that the graphML output of easy-graph returns something different than what is documented by GraphML about attributes for edges and nodes. Here is an example of GraphML with GraphML-Attributes directly taken from the GraphML website: <graph id="G" edgedefault="undirected"> <node id="n0"> <data key="d0">green</data> </node> <node id="n1"/> (see http://graphml.graphdrawing.org/primer/graphml-primer.html) See that when a node has attributes, the end tag </node> appears AFTER the definition of these attributes. However, when Graph-easy outputs graphML, it closes the node tag before the definition of the attribute. For example: <graph id="cluster_0" edgedefault="undirected"> <node id="1" /> <data key="d0">green</data> <node id="2" /> The same applies for edges. http://search.cpan.org/dist/Graph-Easy/bin/graph-easy#GraphML_example_output Is this a bug? Here is a fix: <code> package Graph::Easy::Node; use strict; sub as_graphml { my ($self, $indent, $ids) = @_; my $g = $self->{graph}; my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . "\">\n"; $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{node}); $txt .='</node>\n'; $txt; } ############################################################################# package Graph::Easy::Edge; use strict; sub as_graphml { my ($self, $indent, $ids) = @_; my $g = $self->{graph}; my $txt = $indent . '<edge source="' . $g->_safe_xml($self->{from}->{name}) . '" target="' . $g->_safe_xml($self->{to}->{name}) . "\">\n"; $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{edge}); $txt .='</edge>\n'; $txt; } </code>
Subject: Graph-Easy-0.64.rar

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #46992] GraphML: end tag of nodes before definition of their attributes
Date: Tue, 16 Jun 2009 13:57:51 EDT
To: <bug-Graph-Easy@rt.cpan.org>
From: Tels <nospam-abuse@bloodgate.com>
Yeah, that smeels like a bug, unfortunately I currently do not have time to work on Graph::Easy anymore. Sorry!
On Tue Jun 16 04:16:44 2009, nephtys62 wrote:
Show quoted text
> Hi, > > I noticed that the graphML output of easy-graph returns something > different than what is documented by GraphML about attributes for > edges > and nodes. > > Here is an example of GraphML with GraphML-Attributes directly taken > from the GraphML website: > <graph id="G" edgedefault="undirected"> > <node id="n0"> > <data key="d0">green</data> > </node> > <node id="n1"/> > (see http://graphml.graphdrawing.org/primer/graphml-primer.html) > > See that when a node has attributes, the end tag </node> appears AFTER > the definition of these attributes. > > However, when Graph-easy outputs graphML, it closes the node tag > before > the definition of the attribute. For example: > <graph id="cluster_0" edgedefault="undirected"> > <node id="1" /> > <data key="d0">green</data> > <node id="2" /> > > The same applies for edges. > http://search.cpan.org/dist/Graph-Easy/bin/graph- > easy#GraphML_example_output > > > Is this a bug? > > Here is a fix: > > <code> > package Graph::Easy::Node; > > use strict; > > sub as_graphml > { > my ($self, $indent, $ids) = @_; > > my $g = $self->{graph}; > my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . > "\">\n"; > > $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{node}); > > $txt .='</node>\n'; > > $txt; > } > >
#############################################################################
Show quoted text
> > package Graph::Easy::Edge; > > use strict; > > sub as_graphml > { > my ($self, $indent, $ids) = @_; > > my $g = $self->{graph}; > my $txt = $indent . '<edge source="' . > $g->_safe_xml($self->{from}->{name}) . > '" target="' . $g->_safe_xml($self->{to}->{name}) . > "\">\n"; > > $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{edge}); > > $txt .='</edge>\n'; > > $txt; > } > </code> > >
Hooray, I just fixed this bug. Thanks for making this bug report. Saved me a lot of typing :) Shlomi, this patch is with respect to: https://svn.berlios.de/svnroot/repos/web-cpan/Graph-Easy/trunk
Subject: graph-easy.diff
Index: Graph-Easy/t/graphml_yed.t =================================================================== --- Graph-Easy/t/graphml_yed.t (revision 4571) +++ Graph-Easy/t/graphml_yed.t (working copy) @@ -63,12 +63,15 @@ </key> <graph id="G" edgedefault="directed"> - <node id="A"/> + <node id="A"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d1">blue</data> + </edge> </graph> </graphml> EOT @@ -93,13 +96,16 @@ <key id="d2" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="A"/> + <node id="A"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d1">blue</data> <data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data> + </edge> </graph> </graphml> EOT2 @@ -122,13 +128,16 @@ <key id="d2" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="&lt;&amp;&apos;&quot;&gt;"/> + <node id="&lt;&amp;&apos;&quot;&gt;"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"/> + <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"> <data key="d1">blue</data> <data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data> + </edge> </graph> </graphml> EOT3 @@ -150,14 +159,19 @@ <key id="d0" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="A"/> - <node id="B"/> - <node id="C"/> + <node id="A"> + </node> + <node id="B"> + </node> + <node id="C"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d0">car</data> - <edge source="A" target="C"/> + </edge> + <edge source="A" target="C"> <data key="d0">train</data> + </edge> </graph> </graphml> EOT4 @@ -176,7 +190,8 @@ $result = <<EOT5 <graph id="G" edgedefault="directed"> <graph id="Cities&quot;" edgedefault="directed"> - <node id="Bonn"/> + <node id="Bonn"> + </node> </graph> </graph> </graphml> @@ -199,10 +214,10 @@ $result = <<EOR <?xml version="1.0" encoding="UTF-8"?> -<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" +<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" - xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml + xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd"> EOR Index: Graph-Easy/t/graphml.t =================================================================== --- Graph-Easy/t/graphml.t (revision 4571) +++ Graph-Easy/t/graphml.t (working copy) @@ -63,12 +63,15 @@ </key> <graph id="G" edgedefault="directed"> - <node id="A"/> + <node id="A"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d1">blue</data> + </edge> </graph> </graphml> EOT @@ -93,13 +96,16 @@ <key id="d2" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="A"/> + <node id="A"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d1">blue</data> <data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data> + </edge> </graph> </graphml> EOT2 @@ -122,13 +128,16 @@ <key id="d2" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="&lt;&amp;&apos;&quot;&gt;"/> + <node id="&lt;&amp;&apos;&quot;&gt;"> <data key="d0">red</data> - <node id="B"/> + </node> + <node id="B"> + </node> - <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"/> + <edge source="&lt;&amp;&apos;&quot;&gt;" target="B"> <data key="d1">blue</data> <data key="d2">train-station &amp; &lt;Überlingen &quot;Süd&quot;&gt;</data> + </edge> </graph> </graphml> EOT3 @@ -150,14 +159,19 @@ <key id="d0" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="A"/> - <node id="B"/> - <node id="C"/> + <node id="A"> + </node> + <node id="B"> + </node> + <node id="C"> + </node> - <edge source="A" target="B"/> + <edge source="A" target="B"> <data key="d0">car</data> - <edge source="A" target="C"/> + </edge> + <edge source="A" target="C"> <data key="d0">train</data> + </edge> </graph> </graphml> EOT4 @@ -176,7 +190,8 @@ $result = <<EOT5 <graph id="G" edgedefault="directed"> <graph id="Cities&quot;" edgedefault="directed"> - <node id="Bonn"/> + <node id="Bonn"> + </node> </graph> </graph> </graphml> @@ -199,9 +214,9 @@ $result = <<EOR <?xml version="1.0" encoding="UTF-8"?> -<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" +<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml + xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> EOR Index: Graph-Easy/lib/Graph/Easy/As_graphml.pm =================================================================== --- Graph-Easy/lib/Graph/Easy/As_graphml.pm (revision 4571) +++ Graph-Easy/lib/Graph/Easy/As_graphml.pm (working copy) @@ -111,9 +111,9 @@ my $txt = <<EOF <?xml version="1.0" encoding="UTF-8"?> -<graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" +<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"##Y## - xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml + xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns ##SCHEMA##"> <!-- Created by Graph::Easy v##VERSION## at ##DATE## --> @@ -313,11 +313,13 @@ my ($self, $indent, $ids) = @_; my $g = $self->{graph}; - my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . "\"/>\n"; + my $txt = $indent . '<node id="' . $g->_safe_xml($self->{name}) . "\">\n"; $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{node}); - $txt; + $txt .= "$indent</node>\n"; + + return $txt; } ############################################################################# @@ -332,10 +334,12 @@ my $g = $self->{graph}; my $txt = $indent . '<edge source="' . $g->_safe_xml($self->{from}->{name}) . - '" target="' . $g->_safe_xml($self->{to}->{name}) . "\"/>\n"; + '" target="' . $g->_safe_xml($self->{to}->{name}) . "\">\n"; $txt .= $g->_attributes_as_graphml($self, $indent, $ids->{edge}); + $txt .= "$indent</edge>\n"; + $txt; } Index: Graph-Easy/bin/graph-easy =================================================================== --- Graph-Easy/bin/graph-easy (revision 4571) +++ Graph-Easy/bin/graph-easy (working copy) @@ -634,13 +634,18 @@ <key id="d0" for="edge" attr.name="label" attr.type="string"/> <graph id="G" edgedefault="directed"> - <node id="Berlin"/> - <node id="Bonn"/> - <node id="Ulm"/> - <edge source="Bonn" target="Berlin"/> + <node id="Berlin"> + </node> + <node id="Bonn"> + </node> + <node id="Ulm"> + </node> + <edge source="Bonn" target="Berlin"> <data key="d0">car</data> - <edge source="Bonn" target="Ulm"/> + </edge> + <edge source="Bonn" target="Ulm"> <data key="d0">car</data> + </edge> </graph> <graphml>
Fixed in Graph-Easy-0.70 (just uploaded to CPAN), thanks to ironcamel. Marking as resolved.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.