125 m =
visit(t, map, sp, st);
139 snprintf(name,
sizeof(name),
"cluster_%u", st->
Comp++);
169 nodecnt =
label(e->
node, nodecnt, edgecnt);
189 n_nodes =
label(n, 0, &n_edges);
190 sum_edges += n_edges;
191 sum_nontree += n_edges - n_nodes + 1;
206 *nontree_frac = (float) sum_nontree / (
float) sum_edges;
218 float nontree_frac = 0;
220 gv_stack_t stack = {0};
226 state.N_nodes_in_nontriv_SCC = 0;
241 fprintf(stderr,
"%d %d %d %u %.4f %d %.4f\n",
244 Maxdegree, nontree_frac);
246 fprintf(stderr,
"%d nodes, %d edges, %u strong components\n",
252 -s - only produce statistics\n\
254 -d - allow degenerate components\n\
255 -o<outfile> - write to <outfile> (stdout)\n\
258If no files are specified, stdin is used\n";
272 while ((c = getopt(argc, argv,
":o:sdvS?")) != EOF) {
294 fprintf(stderr,
"%s: option -%c missing argument - ignored\n",
CmdName, optopt);
297 if (optopt ==
'\0' || optopt ==
'?')
300 fprintf(stderr,
"%s: option -%c unrecognized\n",
330 fprintf(stderr,
"Graph %s in %s is undirected - ignored\n",
abstract graph C library, Cgraph API
static NORETURN void graphviz_exit(int status)
int agnedges(Agraph_t *g)
int agdegree(Agraph_t *g, Agnode_t *n, int in, int out)
int agnnodes(Agraph_t *g)
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
#define agopp(e)
opposite edge: flip Agedgepair_s.out ⇄ Agedgepair_s.in/*#end#*/
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
int agisdirected(Agraph_t *g)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
creates a new graph with the given name and kind
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Agdesc_t Agdirected
directed
Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
Agraph_t * agroot(void *obj)
void aginit(Agraph_t *g, int kind, const char *rec_name, int rec_size, int move_to_front)
attach new records to objects of specified kind
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
Agraph_t * agsubg(Agraph_t *g, char *name, int cflag)
static const char * usage
char * fileName(ingraph_state *sp)
Return name of current file being processed.
Agraph_t * nextGraph(ingraph_state *sp)
ingraph_state * newIngraph(ingraph_state *sp, char **files)
supports user-supplied data
static FILE * openFile(const char *argv0, const char *name, const char *mode)
static void setrep(Agraph_t *g, Agnode_t *rep)
static void setscc(Agnode_t *n, Agraph_t *scc)
static void setval(Agnode_t *n, unsigned v)
static void scanArgs(int argc, char **argv)
static void process(Agraph_t *G)
static unsigned visit(Agnode_t *n, Agraph_t *map, gv_stack_t *sp, sccstate *st)
static unsigned getval(Agnode_t *n)
static int countComponents(Agraph_t *g, int *max_degree, float *nontree_frac)
struct Agnodeinfo_t Agnodeinfo_t
static int wantDegenerateComp
static int label(Agnode_t *n, int nodecnt, int *edgecnt)
static Agraph_t * getscc(Agnode_t *n)
struct Agraphinfo_t Agraphinfo_t
static Agnode_t * getrep(Agraph_t *g)
static void nodeInduce(Agraph_t *g, Agraph_t *map)
Implementation of a dynamically expanding stack data structure.
static void stack_push(gv_stack_t *stack, void *item)
static void * stack_pop(gv_stack_t *stack)
static void * stack_top(gv_stack_t *stack)
static void stack_reset(gv_stack_t *stack)
Agrec_t * data
stores programmer-defined data, access with AGDATA
implementation of Agrec_t
int N_nodes_in_nontriv_SCC