[Graph Libraries] Edges in subgraphs
Ported Issue from Mantis Original ID: 303 Reported By: user442
SEVERITY: MINOR Submitted: 2003-11-06 05:00:00
OS: --*
VERSION: 1.10
DESCRIPTION
For a strict, undirected graph, I thought using agedge in a subgraph
when the edge exists would be similar to aginsert. However, in
the example below, ep is a different object from e. Assuming the
semantics are like libagraph, with the edges being different but
representing the same abstract edge, I tried setting the color attribute,
but clearly ep and e have separate attributes. Also, if
comment line A and uncomment line B, we find that the root graph has
two edges between the nodes, which one wouldn't expect in a strict,
undirected graph.
STEPS TO REPRODUCE
typedef char Agraphinfo_t; typedef char Agedgeinfo_t; typedef char Agnodeinfo_t;
include <graph.h>
void prg(Agraph_t* g) { Agnode_t* n; Agedge_t* e;
fprintf (stderr, "%s\n", g->name); for (n = agfstnode(g); n; n = agnxtnode(g,n)) { fprintf (stderr, "%s (%x)\n", n->name, n); for (e = agfstout(g,n); e; e = agnxtout(g,e)) { fprintf (stderr, "%x: %x (%s) -- %x (%s), color = %s\n", e, e->tail, e->tail->name, e->head, e->head->name, agget(e,"color")); } }
}
main () { Agraph_t* g; Agraph_t* sg; Agnode_t* t; Agnode_t* h; Agedge_t* e; Agedge_t* ep;
aginit(); g = agopen ("x", AGFLAG_STRICT); agedgeattr (g, "color",""); t = agnode (g, "a"); h = agnode (g, "b"); e = agedge (g, t, h); agset (e, "color", "blue");
sg = agsubg (g, "y"); aginsert (sg, t); aginsert (sg, h); ep = agedge (sg, t, h); /* line A / / ep = agedge (sg, h, t); / / line B */ agset (ep, "color", "red");
prg (g); prg (sg); }