123 node_stack_push_back(sp, n);
128 m =
visit(t, map, sp, st);
138 (void)node_stack_pop_back(sp);
142 snprintf(name,
sizeof(name),
"cluster_%u", st->Comp++);
147 t = node_stack_pop_back(sp);
151 st->N_nodes_in_nontriv_SCC++;
172 nodecnt =
label(e->
node, nodecnt, edgecnt);
192 n_nodes =
label(n, 0, &n_edges);
193 sum_edges += n_edges;
194 sum_nontree += n_edges - n_nodes + 1;
209 *nontree_frac = (float) sum_nontree / (
float) sum_edges;
221 float nontree_frac = 0;
223 node_stack_t stack = {0};
228 state.
Comp = state.
ID = 0;
237 visit(n, map, &stack, &state);
238 node_stack_free(&stack);
244 fprintf(stderr,
"%d %d %d %u %.4f %d %.4f\n",
247 Maxdegree, nontree_frac);
249 fprintf(stderr,
"%d nodes, %d edges, %u strong components\n",
255 -s - only produce statistics\n\
257 -d - allow degenerate components\n\
258 -o<outfile> - write to <outfile> (stdout)\n\
261If no files are specified, stdin is used\n";
275 while ((c = getopt(argc, argv,
":o:sdvS?")) != EOF) {
297 fprintf(stderr,
"%s: option -%c missing argument - ignored\n",
CmdName, optopt);
300 if (optopt ==
'\0' || optopt ==
'?')
303 fprintf(stderr,
"%s: option -%c unrecognized\n",
333 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
#define DEFINE_LIST(name, type)
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 getval(Agnode_t *n)
static int countComponents(Agraph_t *g, int *max_degree, float *nontree_frac)
static unsigned visit(Agnode_t *n, Agraph_t *map, node_stack_t *sp, sccstate *st)
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)
Agrec_t * data
stores programmer-defined data, access with AGDATA
implementation of Agrec_t
int N_nodes_in_nontriv_SCC