[prev in list] [next in list] [prev in thread] [next in thread]
List: graphviz-devel
Subject: [graphviz-devel] Re: Modifying an edge in a non-strict graph [PATCH]
From: Shaun Jackman <sjackman () bcgsc ! ca>
Date: 2008-12-18 0:32:56
Message-ID: 49499A38.8050905 () bcgsc ! ca
[Download RAW message or body]
Found the bug. A patch follows.
Cheers,
Shaun
2008-12-17 Shaun Jackman <sjackman@gmail.com>
* cmd/gvpr/compile.c (getval) <F_isedge>: The graph argument of
isEdge should be NULL not curgraph.
--- cmd/gvpr/compile.c.orig 2008-12-17 16:27:54.000000000 -0800
+++ cmd/gvpr/compile.c 2008-12-17 16:28:05.053274000 -0800
@@ -799,7 +799,7 @@
error(ERROR_WARNING, "NULL head node passed to isEdge()");
v.integer = 0;
} else
- v.integer = PTR2INT(isEdge(state->curgraph, np, hp, key));
+ v.integer = PTR2INT(isEdge(NULL, np, hp, key));
break;
case F_isedgesg:
#ifdef USE_CGRAPH
Shaun Jackman wrote:
> Okay, I found the solution is to use isEdge. Unfortunately, there's a
> regression from 2.18 to 2.20.3. In 2.20.3, isEdge does not return the
> existing edge as expected. See the test case below.
>
> Cheers,
> Shaun
>
> $ cat weight
> BEG_G { graph_t g = graph ("merge", "U"); }
> E {
> node_t t = clone(g, tail);
> node_t h = clone(g, head);
> edge_t e = isEdge(t, h, "");
> if (e == NULL)
> e = edge(t, h, "");
> e.weight = e.weight + 1;
> }
> END_G { $O = g; }
> $ gvpr-2.18 -f weight <<<'graph g {a--a;a--b;a--b;}'
> graph merge {
> a -- a [weight=1];
> a -- b [weight=2];
> }
> $ gvpr-2.20.3 -f weight <<<'graph g {a--a;a--b;a--b;}'
> graph merge {
> a -- a [weight=1];
> a -- b [weight=1];
> a -- b [weight=1];
> }
>
> Shaun Jackman wrote:
>> Hi,
>>
>> The following example from the gvpr man page `Produces a strict
>> version of the input graph, where the weight attribute of an edge
>> indicates how many edges from the input graph the edge represents.'
>>
>> BEG_G { graph_t g = graph ("merge", "S"); }
>> E {
>> node_t h = clone(g,$.head);
>> node_t t = clone(g,$.tail);
>> edge_t e = edge(t,h,"");
>> e.weight = e.weight + 1;
>> }
>> END_G { $O = g; }
>>
>> Unfortunately, because the graph is strict it also removes loops. In
>> fact, it dies if the input graph contains a loop. If I simply make the
>> output graph non-strict by removing the "S" option to graph(), it no
>> longer works as desired:
>>
>> $ gvpr -f weight <<<'graph g {a--a; a--b; a--b;}'
>> digraph merge {
>> a -> a [weight=1];
>> a -> b [weight=1];
>> a -> b [weight=1];
>> }
>>
>> edge() doesn't return the existing edge as the man page says it does.
>> I presume this behaviour only applies to strict graphs. So, how can I
>> fetch the existing edge rather than creating a new edge in a strict
>> graph?
>>
>> Cheers,
>> Shaun
>
_______________________________________________
graphviz-devel mailing list
graphviz-devel@research.att.com
https://mailman.research.att.com/mailman/listinfo/graphviz-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic