Number: 373
Title: Edges in subgraphs
Submitter: Emden R. Gansner
Date: 6 November 2003
Subsys: libgraph
Version: 1.10
System: *-*-*
Severity: minor
Problem:
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.
Input:
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, "%sn", 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 = %sn",
            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);
}
Owner: *
Status: *