#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;
#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>
*/
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);
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)
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);
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)
int c;
cmd = argv[0];
-#ifndef USE_CGRAPH
- aginit();
-#endif
while ((c = getopt(argc, argv, ":vno:?")) != -1)
switch (c) {
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);
#include "compat_getopt.h"
#endif
-#ifdef USE_CGRAPH
#include <stdlib.h>
-#include <cgraph.h>
+#include "cgraph.h"
typedef struct {
Agrec_t h;
#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))
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;
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) {
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
}
}
}
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
}
}
}
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;
} 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);
{
int c;
-#ifndef USE_CGRAPH
- aginit();
-#endif
while ((c = getopt(argc, argv, ":o:xstv?")) != -1) {
switch (c) {
case 'o':
Files = argv;
}
-#ifdef USE_CGRAPH
static Agraph_t *gread(FILE * fp)
{
return agread(fp, (Agdisc_t *) 0);
}
-#endif
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);