Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gc.c File Reference

count graph components More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cgraph/cgraph.h>
#include <cgraph/cghdr.h>
#include <cgraph/ingraphs.h>
#include <cgraph/list.h>
#include <common/render.h>
#include <common/utils.h>
#include <util/exit.h>
#include <getopt.h>
Include dependency graph for gc.c:

Go to the source code of this file.

Data Structures

struct  nodeinfo_t
 

Macros

#define ND_dfs_mark(n)   (((nodeinfo_t*)(n->base.data))->dfs_mark)
 
#define NODES   1
 
#define EDGES   2
 
#define CC   4
 
#define CL   8
 
#define DIRECTED   1
 
#define UNDIRECTED   2
 
#define GTYPE(g)   (agisdirected(g)?DIRECTED:UNDIRECTED)
 

Functions

static void usage (int v)
 
static void init (int argc, char *argv[])
 
static void push (Agnode_t *np)
 
static Agnode_tpop (void)
 
static void cc_dfs (Agraph_t *g, Agnode_t *n)
 
static void cntCluster (Agraph_t *g, Agobj_t *sg, void *arg)
 
static int cc_decompose (Agraph_t *g)
 
static void ipr (long num)
 
static void wcp (int nnodes, int nedges, int ncc, int ncl, char *gname, char *filename)
 
static void emit (Agraph_t *g, int root, int cl_count)
 
static int eval (Agraph_t *g, int root)
 
int main (int argc, char *argv[])
 

Variables

static int tot_edges
 
static int tot_nodes
 
static int tot_cc
 
static int tot_cl
 
static int n_graphs
 
static int n_indent
 
static int recurse
 
static int silent
 
static int verbose
 
static int gtype
 
static int flags
 
static char * fname
 
static char ** Inputs
 
static FILE * outfile
 
static char * useString
 
static node_stack_t Stk
 

Macro Definition Documentation

◆ CC

#define CC   4

Definition at line 45 of file gc.c.

◆ CL

#define CL   8

Definition at line 46 of file gc.c.

◆ DIRECTED

#define DIRECTED   1

Definition at line 48 of file gc.c.

◆ EDGES

#define EDGES   2

Definition at line 44 of file gc.c.

◆ GTYPE

#define GTYPE (   g)    (agisdirected(g)?DIRECTED:UNDIRECTED)

Definition at line 268 of file gc.c.

◆ ND_dfs_mark

#define ND_dfs_mark (   n)    (((nodeinfo_t*)(n->base.data))->dfs_mark)

Definition at line 39 of file gc.c.

◆ NODES

#define NODES   1

Definition at line 43 of file gc.c.

◆ UNDIRECTED

#define UNDIRECTED   2

Definition at line 49 of file gc.c.

Function Documentation

◆ cc_decompose()

static int cc_decompose ( Agraph_t g)
static

Definition at line 195 of file gc.c.

References agfstnode(), agnxtnode(), cc_dfs(), and ND_dfs_mark.

Referenced by emit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cc_dfs()

static void cc_dfs ( Agraph_t g,
Agnode_t n 
)
static

Definition at line 168 of file gc.c.

References agfstedge(), aghead, agnxtedge(), agtail, ND_dfs_mark, pop(), and push().

Referenced by cc_decompose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cntCluster()

static void cntCluster ( Agraph_t g,
Agobj_t sg,
void *  arg 
)
static

Definition at line 187 of file gc.c.

References AGRAPH, AGTYPE, and is_a_cluster().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit()

static void emit ( Agraph_t g,
int  root,
int  cl_count 
)
static

Definition at line 241 of file gc.c.

References agnameof(), agnedges(), agnnodes(), CC, cc_decompose(), CL, flags, fname, n_graphs, tot_cc, tot_cl, tot_edges, tot_nodes, and wcp().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eval()

static int eval ( Agraph_t g,
int  root 
)
static

Definition at line 270 of file gc.c.

References agapply(), agfstsubg(), aginit(), AGNODE, agnxtsubg(), CL, cntCluster(), emit(), eval(), flags, gtype, GTYPE, n_indent, and recurse.

Referenced by eval(), iterativePCA_1D(), main(), usage(), usage(), usage(), usage(), and usage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

static void init ( int  argc,
char *  argv[] 
)
static

Definition at line 87 of file gc.c.

References CC, CL, DIRECTED, EDGES, flags, graphviz_exit(), gtype, Inputs, NODES, outfile, recurse, silent, tot_cl, UNDIRECTED, usage, and verbose.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ipr()

static void ipr ( long  num)
static

Definition at line 213 of file gc.c.

Referenced by wcp().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 296 of file gc.c.

References agclose(), agnameof(), eval(), fileName(), fname, graphviz_exit(), init(), Inputs, n_graphs, newIngraph(), nextGraph(), NULL, prev, Stk, tot_cc, tot_cl, tot_edges, tot_nodes, verbose, and wcp().

Here is the call graph for this function:

◆ pop()

static Agnode_t * pop ( void  )
static

Definition at line 160 of file gc.c.

References Stk.

Referenced by cc_dfs().

Here is the caller graph for this function:

◆ push()

static void push ( Agnode_t np)
static

Definition at line 154 of file gc.c.

References ND_dfs_mark, and Stk.

Referenced by cc_dfs().

Here is the caller graph for this function:

◆ usage()

static void usage ( int  v)
static

Definition at line 81 of file gc.c.

References graphviz_exit(), and useString.

Here is the call graph for this function:

◆ wcp()

static void wcp ( int  nnodes,
int  nedges,
int  ncc,
int  ncl,
char *  gname,
char *  filename 
)
static

Definition at line 219 of file gc.c.

References CC, CL, EDGES, flags, fname, gname, ipr(), n_indent, nedges, NODES, outfile, and silent.

Referenced by emit(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ flags

◆ fname

char* fname
static

Definition at line 62 of file gc.c.

Referenced by emit(), main(), and wcp().

◆ gtype

int gtype
static

Definition at line 60 of file gc.c.

Referenced by eval(), and init().

◆ Inputs

char** Inputs
static

Definition at line 63 of file gc.c.

Referenced by init(), and main().

◆ n_graphs

int n_graphs
static

Definition at line 55 of file gc.c.

Referenced by emit(), and main().

◆ n_indent

int n_indent
static

Definition at line 56 of file gc.c.

Referenced by eval(), and wcp().

◆ outfile

FILE* outfile
static

Definition at line 64 of file gc.c.

Referenced by init(), and wcp().

◆ recurse

int recurse
static

Definition at line 57 of file gc.c.

Referenced by eval(), and init().

◆ silent

int silent
static

Definition at line 58 of file gc.c.

Referenced by init(), and wcp().

◆ Stk

node_stack_t Stk
static

Definition at line 152 of file gc.c.

Referenced by main(), pop(), and push().

◆ tot_cc

int tot_cc
static

Definition at line 53 of file gc.c.

Referenced by emit(), and main().

◆ tot_cl

int tot_cl
static

Definition at line 54 of file gc.c.

Referenced by emit(), init(), and main().

◆ tot_edges

int tot_edges
static

Definition at line 51 of file gc.c.

Referenced by emit(), and main().

◆ tot_nodes

int tot_nodes
static

Definition at line 52 of file gc.c.

Referenced by emit(), and main().

◆ useString

char* useString
static
Initial value:
= "Usage: gc [-necCaDUrsv?] <files>\n\
-n - print number of nodes\n\
-e - print number of edges\n\
-c - print number of connected components\n\
-C - print number of clusters\n\
-a - print all counts\n\
-D - only directed graphs\n\
-U - only undirected graphs\n\
-r - recursively analyze subgraphs\n\
-s - silent\n\
-v - verbose\n\
-? - print usage\n\
By default, gc prints nodes and edges\n\
If no files are specified, stdin is used\n"

Definition at line 66 of file gc.c.

Referenced by usage().

◆ verbose

int verbose
static

Definition at line 59 of file gc.c.

Referenced by init(), and main().