40 static int margin = 8;
41 static int doEdges = 1;
42 static int doComps = 0;
43 static int verbose = 0;
44 static char **
Files = 0;
45 static int nFiles = 0;
46 static int single = 0;
48 static char *useString =
"Usage: ptest [-cesv?] [-m <margine>] <files>\n\
55 If no files are specified, stdin is used\n";
57 static void usage(
int v)
63 static void init(
int argc,
char *argv[])
68 while ((c = getopt(argc, argv,
":escvm:?")) != -1) {
77 margin = atoi(optarg);
91 "ptest: option -%c unrecognized - ignored\n", c);
105 static int numFields(
char *pos)
110 while (isspace(*pos))
114 while ((c = *pos) && !isspace(c))
116 while (isspace(*pos))
132 pos =
agxget(e, symptr->index);
141 i = sscanf(pos,
"%lf,%lf%n", &x, &y, &nc);
171 fprintf(stderr,
"Warning: turning off doEdges, graph %s\n",
177 p =
agxget(n, N_pos->index);
178 if (p[0] && (sscanf(p,
"%lf,%lf", pvec, pvec + 1) == 2)) {
180 for (i = 0; i < NDIM; i++)
183 fprintf(stderr,
"could not find pos for node %s in graph %s\n",
194 if ((sp = user_spline(E_pos, e, &pn)) != 0) {
199 "Missing edge pos for edge %s - %s in graph %s\n",
200 n->name, e->head->name, g->name);
208 static void ptest_nodesize(
node_t * n,
boolean flip)
218 static void ptest_initNode(
node_t * n)
239 ptest_nodesize(n, n->GD_flip(
graph));
244 static void ptest_initGraph(
graph_t * g)
265 fprintf(stderr,
" node %s \n", n->name);
268 fprintf(stderr,
" %s - %s \n", e->tail->name, e->head->name);
272 fprintf(stderr,
" %s pos (%f,%f) (%d,%d)\n",
274 fprintf(stderr,
" width %f height %f xsize %d ysize %d\n",
302 fprintf(stderr,
"No input files given\n");
309 fprintf(stderr,
"do Comps\n");
310 while (fname = *
Files++) {
311 fp = fopen(fname,
"r");
313 fprintf(stderr,
"Could not open %s\n", fname);
319 fprintf(stderr,
"Could not read graph\n");
322 printf(
"%s %d nodes %d edges %sconnected\n",
325 gs =
ccomps(g, &cnt,
"abc");
326 for (i = 0; i < cnt; i++) {
328 printf(
" %s %d nodes %d edges\n", gp->name,
agnnodes(gp),
335 while (fname =
Files[cnt]) {
336 fp = fopen(fname,
"r");
338 fprintf(stderr,
"Could not open %s\n", fname);
344 fprintf(stderr,
"Could not read graph\n");
365 for (i = 0; i < cnt; i++) {
370 "Error: node %s in graph %d (%s) previously added\n",
371 n->name, i,
Files[i]);
374 np =
agnode(root, n->name);
377 ND_coord_i(np).x = ND_coord_i(n).x;
378 ND_coord_i(np).y = ND_coord_i(n).y;
384 ep =
agedge(root, tp, hp);
390 ptest_initGraph(root);
391 ccs =
ccomps(root, &cnt, 0);
398 for (i = 0; i < cnt; i++) {
406 for (i = 0; i < cnt; i++) {
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
#define DEFAULT_NODEWIDTH
char * late_nnstring(void *obj, attrsym_t *attr, char *def)
EXTERN Agsym_t * N_fontname
EXTERN Agsym_t * N_fontcolor
EXTERN Agsym_t * N_fontsize
#define ALLOC(size, ptr, type)
EXTERN Agsym_t * N_height
#define DEFAULT_NODEHEIGHT
CGRAPH_API Agraph_t * agread(void *chan, Agdisc_t *disc)
void clip_and_install(edge_t *fe, node_t *hn, pointf *ps, int pn, splineInfo *info)
CGRAPH_API int agdelete(Agraph_t *g, void *obj)
CGRAPH_API int agwrite(Agraph_t *g, void *chan)
int packGraphs(int ng, Agraph_t **gs, Agraph_t *root, pack_info *info)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
#define agfindedgeattr(g, a)
#define agedgeattr(g, n, s)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
CGRAPH_API void aginit(Agraph_t *g, int kind, char *rec_name, int rec_size, int move_to_front)
Agraph_t * graph(char *name)
double late_double(void *obj, attrsym_t *attr, double def, double low)
EXTERN unsigned char Verbose
CGRAPH_API int agnnodes(Agraph_t *g)
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
#define DEFAULT_NODESHAPE
CGRAPH_API int agnedges(Agraph_t *g)
Agraph_t ** ccomps(Agraph_t *g, int *ncc, char *pfx)
EXTERN double PSinputscale
char * agxget(void *obj, Agsym_t *sym)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
int isConnected(Agraph_t *g)
void attach_attrs(graph_t *g)
#define agfindnodeattr(g, a)
shape_desc * bind_shape(char *name, node_t *)
int main(int argc, char **argv)
textlabel_t * make_label(void *obj, char *str, int kind, double fontsize, char *fontname, char *fontcolor)