]> granicus.if.org Git - graphviz/commitdiff
Fix code to use cgraph
authorerg <devnull@localhost>
Thu, 23 Oct 2008 15:18:16 +0000 (15:18 +0000)
committererg <devnull@localhost>
Thu, 23 Oct 2008 15:18:16 +0000 (15:18 +0000)
lib/common/types.h
lib/neatogen/stuff.c

index 15e9b580b4bd33ed886a6b3c058ad4f0b248cfac..29306abfa2ac73b36d5b5b9122000cb77b1ad058 100644 (file)
@@ -435,6 +435,8 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind;
 #define GD_showboxes(g) (((Agraphinfo_t*)AGDATA(g))->showboxes)
 #define GD_fontnames(g) (((Agraphinfo_t*)AGDATA(g))->fontnames)
 #define GD_spring(g) (((Agraphinfo_t*)AGDATA(g))->spring)
+#define GD_sum_t(g) (((Agraphinfo_t*)AGDATA(g))->sum_t)
+#define GD_t(g) (((Agraphinfo_t*)AGDATA(g))->t)
 
 #else
 
index 0dc8d81fd6152e35a5c2f0b80f1016623e37e412..65d29e272a157757cf425033f2a2bea99fea5e8b 100644 (file)
@@ -115,16 +115,27 @@ static void free_3array(double ***rv)
     }
 }
 
+
+#ifdef WITH_CGRAPH
+static double doubleattr(void *obj, Agsym_t* index, double defval)
+#else
 static double doubleattr(void *obj, int index, double defval)
+#endif
 {
     double val;
+
+#ifdef WITH_CGRAPH
+    if (index == NULL)
+#else
     if (index < 0)
+#endif
        return defval;
     if (sscanf(agxget(obj, index), "%lf", &val) < 1)
        return defval;
     return val;
 }
 
+
 /* degreeKind;
  * Returns degree of n ignoring loops and multiedges.
  * Returns 0, 1 or many (2)
@@ -190,7 +201,11 @@ static node_t *prune(graph_t * G, node_t * np, node_t * next)
     return next;
 }
 
+#ifdef WITH_CGRAPH
+static double setEdgeLen(graph_t * G, node_t * np, Agsym_t* lenx)
+#else
 static double setEdgeLen(graph_t * G, node_t * np, int lenx)
+#endif
 {
     edge_t *ep;
     double total_len = 0.0;
@@ -216,12 +231,14 @@ static double setEdgeLen(graph_t * G, node_t * np, int lenx)
  */
 int scan_graph_mode(graph_t * G, int mode)
 {
-    int i, lenx, nV, nE, deg;
+    int i, nV, nE, deg;
     char *str;
     node_t *np, *xp, *other;
     double total_len = 0.0;
 #ifdef WITH_CGRAPH
-    int c=0;
+    Agsym_t* lenx;
+#else
+    int lenx;
 #endif /* WITH_CGRAPH */
 
     if (Verbose)
@@ -245,7 +262,11 @@ int scan_graph_mode(graph_t * G, int mode)
     nV = agnnodes(G);
     nE = agnedges(G);
 
+#ifdef WITH_CGRAPH
+    lenx = agattr(G, AGEDGE, "len", 0);
+#else
     lenx = agindex(G->root->proto->e, "len");
+#endif
     if (mode == MODE_KK) {
        Epsilon = .0001 * nV;
        getdouble(G, "epsilon", &Epsilon);
@@ -292,7 +313,6 @@ int scan_graph(graph_t * g)
 
 void free_scan_graph(graph_t * g)
 {
-#ifndef WITH_CGRAPH
     free(GD_neato_nlist(g));
     if (!Nop) {
        free_array(GD_dist(g));
@@ -301,7 +321,6 @@ void free_scan_graph(graph_t * g)
        free_3array(GD_t(g));
        GD_t(g) = NULL;
     }
-#endif /* WITH_CGRAPH */
 }
 
 void jitter_d(node_t * np, int nG, int n)