40#define ON_STACK(ninfo, n) (ninfo[AGSEQ(n)].on_stack)
41#define DISTANCE(ninfo, n) (ninfo[AGSEQ(n)].dist)
42#define agrootof(n) ((n)->root)
44static unsigned char uchar_min(
unsigned char a,
unsigned char b) {
120 edge_stack_t estk = {0};
121 push(&estk, &dummy.
out, ninfo);
124 while ((link =
top(&estk))) {
130 for (; next; next =
agnxtout(g, next)) {
140 "warning: %s has cycle(s), transitive reduction not unique\n",
142 fprintf(
opts->err,
"cycle involves edge %s -> %s\n",
agnameof(v),
146 }
else if (
DISTANCE(ninfo, hd) == 0) {
149 }
else if (
DISTANCE(ninfo, hd) == 1) {
154 push(&estk, next, ninfo);
161 for (e =
agfstout(g, n); e; e = f) {
174 fprintf(
opts->err,
"removed edge: %s: \"%s\" -> \"%s\"\n",
agnameof(g),
189 time_t total_secs = 0;
195 fprintf(stderr,
"Processing graph %s\n",
agnameof(g));
197 memset(ninfo, 0, infosize);
198 const time_t start = time(
NULL);
199 warn =
dfs(n, ninfo, warn,
opts);
201 const time_t secs = time(
NULL) - start;
205 fprintf(
opts->err,
"[%d]\n",
cnt);
210 fprintf(
opts->err,
"Finished graph %s: %lld.00 secs.\n",
agnameof(g),
211 (
long long)total_secs);
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
size_t node_set_size(const node_set_t *self)
static gstack_t * push(gstack_t *s, Agraph_t *subg)
static int cnt(Dict_t *d, Dtlink_t **set)
void graphviz_tred(Agraph_t *g, const graphviz_tred_options_t *opts)
programmatic access to tred - transitive reduction
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
char * agnameof(void *)
returns a string descriptor for the object.
int agdelete(Agraph_t *g, void *obj)
deletes object. Equivalent to agclose, agdelnode, and agdeledge for obj being a graph,...
static int dfs(Agnode_t *n, nodeinfo_t *ninfo, int warn, const graphviz_tred_options_t *opts)
static unsigned char uchar_min(unsigned char a, unsigned char b)
#define ON_STACK(ninfo, n)
#define DISTANCE(ninfo, n)
static Agedge_t * top(edge_stack_t *sp)
type-generic dynamically expanding list
#define LIST_POP_BACK(list)
#define LIST_IS_EMPTY(list)
#define LIST_PUSH_BACK(list, item)
unordered set of Agsubnode_t *
Agtag_t tag
access with AGTAG
struct graphviz_node_set * n_id
the node set indexed by ID
unsigned objtype
access with AGTYPE
options for passing to graphviz_tred