]> granicus.if.org Git - graphviz/commitdiff
Removing all existing usage of USE_CGRAPH
authorellson <devnull@localhost>
Thu, 7 Aug 2008 17:17:46 +0000 (17:17 +0000)
committerellson <devnull@localhost>
Thu, 7 Aug 2008 17:17:46 +0000 (17:17 +0000)
    cgraph is now in full production in all these files

configure.ac still contains the --with-cgraph option in case Arif wants to use it.

cmd/tools/acyclic.c
cmd/tools/bcomps.c

index 3f138f96344558c84cf739eda20ab24bf693bda0..0f1d29dd9eca02f0334d019386cbf38088537e9b 100644 (file)
 #endif
 
 #ifdef HAVE_UNISTD_H
-#include       <unistd.h>
+#include <unistd.h>
 #endif
 #include <stdio.h>
-#ifdef USE_CGRAPH
+
 #include <stdlib.h>
-#include <cgraph.h>
+#include "cgraph.h"
 typedef struct {
     Agrec_t h;
     int mark;
@@ -40,22 +40,6 @@ typedef struct {
 #define ND_mark(n) (((Agnodeinfo_t*)((n)->base.data))->mark)
 #define ND_onstack(n) (((Agnodeinfo_t*)((n)->base.data))->onstack)
 #define graphName(g) (agnameof(g))
-#else
-typedef char Agraphinfo_t;
-typedef char Agedgeinfo_t;
-typedef struct {
-    int mark;
-    int onstack;
-} Agnodeinfo_t;
-
-#define ND_mark(n) (n)->u.mark
-#define ND_onstack(n) (n)->u.onstack
-#define aghead(e) ((e)->head)
-#define agtail(e) ((e)->tail)
-#define graphName(g) ((g)->name)
-
-#include <graph.h>
-#endif
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -77,7 +61,6 @@ static char *cmd;
  */
 static void addRevEdge(Agraph_t * g, Agedge_t * e)
 {
-#ifdef USE_CGRAPH
     Agsym_t* sym;
     Agedge_t* f = agedge (g, aghead(e), agtail(e), agnameof(e), 1);
 
@@ -87,26 +70,6 @@ static void addRevEdge(Agraph_t * g, Agedge_t * e)
     if (sym) agsafeset (f, HEADPORT_ID, agxget (e, sym), "");
     sym = agattr (g, AGEDGE, HEADPORT_ID, 0);
     if (sym) agsafeset (f, TAILPORT_ID, agxget (e, sym), "");
-#else
-    Agedge_t *reve;
-    char *tmps;
-    char **attrs;
-    extern char *agstrdup(char *);
-
-    attrs = g->proto->e->attr;
-    g->proto->e->attr = e->attr;
-    tmps = e->attr[0];
-    e->attr[0] = "";
-    reve = agedge(g, e->head, e->tail);
-    e->attr[0] = tmps;
-    g->proto->e->attr = attrs;
-
-    /* copy key attribute, and reverse head and tail port attributes */
-    reve->attr[0] = agstrdup(tmps);
-    tmps = reve->attr[1];
-    reve->attr[1] = reve->attr[2];
-    reve->attr[2] = tmps;
-#endif
 }
 
 static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle)
@@ -123,7 +86,6 @@ static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle)
            continue;
        h = aghead(e);
        if (ND_onstack(h)) {
-#ifdef USE_CGRAPH
            if (agisstrict(g)) {
                if (agedge(g, h, t, 0, 0) == 0)
                    addRevEdge(g, e);
@@ -132,13 +94,6 @@ static int dfs(Agraph_t * g, Agnode_t * t, int hasCycle)
                if (!key || (agedge(g, h, t, key, 0) == 0))
                    addRevEdge(g, e);
            }
-#else
-           if (AG_IS_STRICT(g)) {
-               if (agfindedge(g, h, t) == 0)
-                   addRevEdge(g, e);
-           } else
-               addRevEdge(g, e);
-#endif
            agdelete(g, e);
            hasCycle = 1;
        } else if (ND_mark(h) == 0)
@@ -183,9 +138,6 @@ static void init(int argc, char *argv[])
     int c;
 
     cmd = argv[0];
-#ifndef USE_CGRAPH
-    aginit();
-#endif
 
     while ((c = getopt(argc, argv, ":vno:?")) != -1)
        switch (c) {
@@ -230,14 +182,9 @@ int main(int argc, char *argv[])
 
     init(argc, argv);
 
-#ifdef USE_CGRAPH
     if ((g = agread(inFile,  (Agdisc_t *) 0)) != 0) {
        if (agisdirected (g)) {
            aginit(g, AGNODE, "info", sizeof(Agnodeinfo_t), TRUE);
-#else
-    if ((g = agread(inFile)) != 0) {
-       if (AG_IS_DIRECTED(g)) {
-#endif
            for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
                if (ND_mark(n) == 0)
                    rv |= dfs(g, n, 0);
index a92e6944da39c16ec1bf3bf77255d6c163d2b564..e73c5fc578ce4b2faed203a5c32c18cb7ec94278 100644 (file)
@@ -33,9 +33,8 @@
 #include "compat_getopt.h"
 #endif
 
-#ifdef USE_CGRAPH
 #include <stdlib.h>
-#include <cgraph.h>
+#include "cgraph.h"
 
 typedef struct {
     Agrec_t h;
@@ -59,34 +58,8 @@ typedef struct {
 #define N(n)  (((Agnodeinfo_t*)(n->base.data))->val)
 #define NEXT(e)  (((Agedgeinfo_t*)(e->base.data))->next)
 #define NEXTBLK(g)  (((Agraphinfo_t*)(g->base.data))->next)
-#else
-typedef struct {
-    struct Agraph_t *next;
-} Agraphinfo_t;
-
-typedef struct {
-    struct Agedge_t *next;
-} Agedgeinfo_t;
-
-typedef struct {
-    int low;
-    int val;
-    int isCut;
-} Agnodeinfo_t;
 
-#include <graph.h>
-
-#define Low(n) ((n)->u.low)
-#define Cut(n) ((n)->u.isCut)
-#define N(n) ((n)->u.val)
-#define NEXT(e) ((e)->u.next)
-#define NEXTBLK(g) ((g)->u.next)
-
-#define aghead(e) ((e)->head)
-#define agtail(e) ((e)->tail)
-#define agnameof(g) ((g)->name)
-#endif
-#include <ingraphs.h>
+#include "ingraphs.h"
 
 #define min(a,b) ((a) < (b) ? (a) :  (b))
 
@@ -203,12 +176,8 @@ static Agraph_t *mkBlock(Agraph_t * g, bcstate * stp)
     Agraph_t *sg;
 
     stp->nComp++;
-#ifdef USE_CGRAPH
     sg = agsubg(g, blockName(agnameof(g), stp->nComp), 1);
     agbindrec(sg, "info", sizeof(Agraphinfo_t), TRUE);
-#else
-    sg = agsubg(g, blockName(g->name, stp->nComp));
-#endif
     NEXTBLK(sg) = stp->blks;
     stp->blks = sg;
     return sg;
@@ -238,13 +207,8 @@ dfs(Agraph_t * g, Agnode_t * u, bcstate * stp, Agnode_t * parent)
                sg = mkBlock(g, stp);
                do {
                    ep = pop(&stp->stk);
-#ifdef USE_CGRAPH
                    agsubnode(sg, aghead(ep), 1);
                    agsubnode(sg, agtail(ep), 1);
-#else
-                   aginsert(sg, ep->head);
-                   aginsert(sg, ep->tail);
-#endif
                } while (ep != e);
            }
        } else if (parent != v) {
@@ -262,13 +226,8 @@ static void nodeInduce(Agraph_t * g, Agraph_t * eg)
 
     for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
        for (e = agfstout(eg, n); e; e = agnxtout(eg, e)) {
-#ifdef USE_CGRAPH
            if (agsubnode(g, aghead(e), 0)) {
                agsubedge(g, e, 1);
-#else
-           if (agcontains(g, e->head)) {
-               aginsert(g, e);
-#endif
            }
        }
     }
@@ -280,20 +239,11 @@ static void addCutPts(Agraph_t * tree, Agraph_t * blk)
     Agnode_t *bn;
     Agnode_t *cn;
 
-#ifdef USE_CGRAPH
     bn = agnode(tree, agnameof(blk), 1);
-#else
-    bn = agnode(tree, agnameof(blk));
-#endif
     for (n = agfstnode(blk); n; n = agnxtnode(blk, n)) {
        if (Cut(n)) {
-#ifdef USE_CGRAPH
            cn = agnode(tree, agnameof(n), 1);
            agedge(tree, bn, cn, 0, 1);
-#else
-           cn = agnode(tree, n->name);
-           agedge(tree, bn, cn);
-#endif
        }
     }
 }
@@ -306,11 +256,9 @@ static int process(Agraph_t * g, int gcnt)
     Agraph_t *tree;
     int bcnt;
 
-#ifdef USE_CGRAPH
     aginit(g, AGNODE, "info", sizeof(Agnodeinfo_t), TRUE);
     aginit(g, AGEDGE, "info", sizeof(Agedgeinfo_t), TRUE);
     aginit(g, AGRAPH, "info", sizeof(Agraphinfo_t), TRUE);
-#endif
 
     state.count = 0;
     state.nComp = 0;
@@ -332,11 +280,7 @@ static int process(Agraph_t * g, int gcnt)
     } else
        gwrite(g, gcnt, 0);
     if (doTree) {
-#ifdef USE_CGRAPH
        tree = agopen("blkcut_tree", Agstrictundirected, 0);
-#else
-       tree = agopen("blkcut_tree", AGFLAG_STRICT);
-#endif
        for (blk = state.blks; blk; blk = NEXTBLK(blk))
            addCutPts(tree, blk);
        gwrite(tree, gcnt, -1);
@@ -396,9 +340,6 @@ static void init(int argc, char *argv[])
 {
     int c;
 
-#ifndef USE_CGRAPH
-    aginit();
-#endif
     while ((c = getopt(argc, argv, ":o:xstv?")) != -1) {
        switch (c) {
        case 'o':
@@ -434,12 +375,10 @@ static void init(int argc, char *argv[])
        Files = argv;
 }
 
-#ifdef USE_CGRAPH
 static Agraph_t *gread(FILE * fp)
 {
   return agread(fp, (Agdisc_t *) 0);
 }
-#endif
 
 int main(int argc, char *argv[])
 {
@@ -449,11 +388,7 @@ int main(int argc, char *argv[])
     int gcnt = 0;
 
     init(argc, argv);
-#ifdef USE_CGRAPH
     newIngraph(&ig, Files, gread);
-#else
-    newIngraph(&ig, Files, agread);
-#endif
 
     while ((g = nextGraph(&ig)) != 0) {
        r |= process(g, gcnt);