From 71034c819b8dc35563b050b8a8da1dde8763121b Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 24 Jul 2009 21:07:32 +0000 Subject: [PATCH] Process multiedges --- cmd/smyrna/topview.c | 38 +++++++++++++++++++++++++++++++++++++- cmd/smyrna/topview.h | 1 + 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cmd/smyrna/topview.c b/cmd/smyrna/topview.c index 6299c425f..aa1e8e594 100755 --- a/cmd/smyrna/topview.c +++ b/cmd/smyrna/topview.c @@ -33,6 +33,7 @@ #include "arith.h" #include "topfisheyeview.h" #include "beacon.h" +#include "pointset.h" #ifdef WIN32 #include "regex_win32.h" #else @@ -137,10 +138,12 @@ static void setRGBcolor(RGBColor* c,char* colorstr) } - +#undef DIST2 +#undef DIST #define DIST2(x,y) (((x)*(x))+((y)*(y))) #define DIST(x,y) (sqrt(DIST2(x,y))) + /*update position info from cgraph*/ void settvposinfo(Agraph_t* g,topview* t) { @@ -1951,6 +1954,39 @@ static void draw_xdot_set(xdot_set* s) } } +void setMultiedges (Agraph_t* g, char* attrname) +{ + Agsym_t* attr = agattr (g, AGEDGE, attrname, 0); + Agnode_t* n; + Agedge_t* e; + PointMap* map = newPM(); + int tid, hid, u, v, idx; + char buf[128]; + + if (!attr) + attr = agattr (g, AGEDGE, attrname, "0"); + + for (n = agfstnode (g); n; n = agnxtnode (g, n)) { + tid = AGID(n); + for (e = agfstout (g, n); e; e = agnxtout (g, e)) { + hid = AGID(AGHEAD(e)); + if (tid < hid) { + u = tid; + v = hid; + } + else { + u = hid; + v = tid; + } + idx = insertPM (map, u, v, 0); + sprintf (buf, "%d", idx); + agxset (e, attr, buf); + updatePM (map, u, v, idx+1); + } + } + freePM(map); +} + #ifdef DEBUG void print_xdot_set(xdot_set* s) { diff --git a/cmd/smyrna/topview.h b/cmd/smyrna/topview.h index f7e44d1e5..b46e73e4e 100755 --- a/cmd/smyrna/topview.h +++ b/cmd/smyrna/topview.h @@ -35,5 +35,6 @@ void originate_distorded_coordinates(topview * t); float calcfontsize(float totaledgelength,int totallabelsize,int edgecount,int totalnodecount); void select_with_regex(char* exp); void settvcolorinfo(Agraph_t* g,topview* t); +void setMultiedges (Agraph_t* g, char* attrname); #endif -- 2.40.0