39#define ND_dfs_mark(n) (((nodeinfo_t*)(n->base.data))->dfs_mark)
66static char *
useString =
"Usage: gc [-necCaDUrsv?] <files>\n\
67 -n - print number of nodes\n\
68 -e - print number of edges\n\
69 -c - print number of connected components\n\
70 -C - print number of clusters\n\
71 -a - print all counts\n\
72 -D - only directed graphs\n\
73 -U - only undirected graphs\n\
74 -r - recursively analyze subgraphs\n\
78By default, gc prints nodes and edges\n\
79If no files are specified, stdin is used\n";
87static void init(
int argc,
char *argv[])
92 while ((c = getopt(argc, argv,
"necCaDUrsv?")) != -1) {
126 if (optopt ==
'\0' || optopt ==
'?')
129 fprintf(stderr,
"gc: option -%c unrecognized\n",
135 fprintf(stderr,
"gc: unexpected error\n");
157 node_stack_push_back(&
Stk, np);
162 if (node_stack_is_empty(&
Stk)) {
165 return node_stack_pop_back(&
Stk);
174 while ((n =
pop())) {
215 printf(
" %7ld", num);
236 printf(
" %s (%s)\n",
gname, filename);
238 printf(
" %s\n",
gname);
257 wcp(n_nodes, n_edges, n_cc, n_cl,
agnameof(g), file);
268#define GTYPE(g) (agisdirected(g)?DIRECTED:UNDIRECTED)
285 emit(g, root, cl_count);
296int main(
int argc,
char *argv[])
312 fprintf(stderr,
"Process graph %s in file %s\n",
agnameof(g),
320 node_stack_free(&
Stk);
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
abstract graph C library, Cgraph API
bool is_a_cluster(Agraph_t *g)
static NORETURN void graphviz_exit(int status)
static void init(int argc, char *argv[])
static void ipr(long num)
static int cc_decompose(Agraph_t *g)
static void wcp(int nnodes, int nedges, int ncc, int ncl, char *gname, char *filename)
static Agnode_t * pop(void)
static void cntCluster(Agraph_t *g, Agobj_t *sg, void *arg)
static int eval(Agraph_t *g, int root)
static void emit(Agraph_t *g, int root, int cl_count)
static void cc_dfs(Agraph_t *g, Agnode_t *n)
static void push(Agnode_t *np)
int agnedges(Agraph_t *g)
int agnnodes(Agraph_t *g)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
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.
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
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
Agraph_t * agfstsubg(Agraph_t *g)
Agraph_t * agnxtsubg(Agraph_t *subg)
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 int nedges
total no. of edges used in routing
a generic header of Agraph_s, Agnode_s and Agedge_s
implementation of Agrec_t