int main(int argc, char **argv) { graph_t *prev = NULL; int r, rc = 0; Gvc = gvContextPlugins(lt_preloaded_symbols, DEMAND_LOADING); GvExitOnUsage = 1; gvParseArgs(Gvc, argc, argv); #ifndef _WIN32 signal(SIGUSR1, gvToggle); signal(SIGINT, intr); #ifndef NO_FPERR signal(SIGFPE, fperr); #endif #endif if (MemTest) { while (MemTest--) { /* Create a test graph */ G = create_test_graph(); /* Perform layout and cleanup */ gvLayoutJobs(Gvc, G); /* take layout engine from command line */ gvFreeLayout(Gvc, G); agclose (G); } } else if ((G = gvPluginsGraph(Gvc))) { gvLayoutJobs(Gvc, G); /* take layout engine from command line */ gvRenderJobs(Gvc, G); } else { while ((G = gvNextInputGraph(Gvc))) { if (prev) { gvFreeLayout(Gvc, prev); agclose(prev); } gvLayoutJobs(Gvc, G); /* take layout engine from command line */ gvRenderJobs(Gvc, G); gvFinalize(Gvc); r = agreseterrors(); rc = MAX(rc,r); prev = G; } } r = gvFreeContext(Gvc); return (MAX(rc,r)); }
/* Render layout in a specified format to an open FILE */ int gvRender(GVC_t *gvc, graph_t *g, const char *format, FILE *out) { int rc; GVJ_t *job; g = g->root; /* create a job for the required format */ rc = gvjobs_output_langname(gvc, format); job = gvc->job; if (rc == NO_SUPPORT) { agerr (AGERR, "Format: \"%s\" not recognized. Use one of:%s\n", format, gvplugin_list(gvc, API_device, format)); return -1; } job->output_lang = gvrender_select(job, job->output_langname); if (!LAYOUT_DONE(g) && !(job->flags & LAYOUT_NOT_REQUIRED)) { agerrorf( "Layout was not done\n"); return -1; } job->output_file = out; if (out == NULL) job->flags |= OUTPUT_NOT_REQUIRED; rc = gvRenderJobs(gvc, g); gvrender_end_job(job); gvjobs_delete(gvc); return rc; }
void GraphvizAdapterImpl::finalize() { gvLayoutJobs(gvc_, g_); gvRenderJobs(gvc_, g_); gvFreeLayout(gvc_, g_); finalize_graph_(); finalize_context_(); }
/* Render layout in a specified format to an external context */ int gvRenderContext(GVC_t *gvc, graph_t *g, const char *format, void *context) { int rc; GVJ_t *job; g = g->root; /* create a job for the required format */ rc = gvjobs_output_langname(gvc, format); job = gvc->job; if (rc == NO_SUPPORT) { agerr(AGERR, "Format: \"%s\" not recognized. Use one of:%s\n", format, gvplugin_list(gvc, API_device, format)); return -1; } job->output_lang = gvrender_select(job, job->output_langname); if (!GD_drawing(g) && !(job->flags & LAYOUT_NOT_REQUIRED)) { fprintf(stderr, "Layout was not done\n"); return -1; } job->context = context; job->external_context = TRUE; gvRenderJobs(gvc, g); gvrender_end_job(job); gvdevice_finalize(job); gvjobs_delete(gvc); return 0; }
static void intr(int s) { /* if interrupted we try to produce a partial rendering before exiting */ if (G) gvRenderJobs(Gvc, G); /* Note that we don't call gvFinalize() so that we don't start event-driven * devices like -Tgtk or -Txlib */ exit (gvFreeContext(Gvc)); }
/* Render layout in a specified format to a malloc'ed string */ int gvRenderData(GVC_t *gvc, graph_t *g, const char *format, char **result, unsigned int *length) { int rc; GVJ_t *job; g = g->root; /* create a job for the required format */ rc = gvjobs_output_langname(gvc, format); job = gvc->job; if (rc == NO_SUPPORT) { agerr(AGERR, "Format: \"%s\" not recognized. Use one of:%s\n", format, gvplugin_list(gvc, API_device, format)); return -1; } job->output_lang = gvrender_select(job, job->output_langname); if (!LAYOUT_DONE(g) && !(job->flags & LAYOUT_NOT_REQUIRED)) { agerrorf( "Layout was not done\n"); return -1; } /* page size on Linux, Mac OS X and Windows */ #define OUTPUT_DATA_INITIAL_ALLOCATION 4096 if(!result || !(*result = malloc(OUTPUT_DATA_INITIAL_ALLOCATION))) { agerr(AGERR, "failure malloc'ing for result string"); return -1; } job->output_data = *result; job->output_data_allocated = OUTPUT_DATA_INITIAL_ALLOCATION; job->output_data_position = 0; rc = gvRenderJobs(gvc, g); gvrender_end_job(job); if (rc == 0) { *result = job->output_data; *length = job->output_data_position; } gvjobs_delete(gvc); return rc; }
int main(int argc, char **argv) { graph_t *g, *prev = NULL; GVC_t *gvc; gvc = gvContext(); gvParseArgs(gvc, argc, argv); while ((g = gvNextInputGraph(gvc))) { if (prev) { gvFreeLayout(gvc, prev); agclose(prev); } gvLayoutJobs(gvc, g); gvRenderJobs(gvc, g); prev = g; } return (gvFreeContext(gvc)); }
int main(int argc, char **argv) { graph_t *prev = NULL; Gvc = gvNEWcontext(Info, gvUsername()); gvParseArgs(Gvc, argc, argv); #ifndef WIN32 signal(SIGUSR1, gvToggle); signal(SIGINT, intr); #ifndef NO_FPERR fpinit(); signal(SIGFPE, fperr); #endif #endif if (MemTest) { while (1) { /* Create a test graph */ G = create_test_graph(); /* Perform layout and cleanup */ gvLayoutJobs(Gvc, G); /* take layout engine from command line */ gvFreeLayout(Gvc, G); /* Delete graph */ agclose(G); } } else { while ((G = gvNextInputGraph(Gvc))) { if (prev) { gvFreeLayout(Gvc, prev); agclose(prev); } gvLayoutJobs(Gvc, G); /* take layout engine from command line */ gvRenderJobs(Gvc, G); prev = G; } } return (gvFreeContext(Gvc)); }
int main(int argc, char **argv) { Agraph_t *g; Agnode_t *n, *m; Agedge_t *e; GVC_t *gvc; /* set up a graphviz context */ gvc = gvContext(); /* parse command line args - minimally argv[0] sets layout engine */ gvParseArgs(gvc, argc, argv); /* Create a simple digraph */ g = agopen("g", AGDIGRAPH); n = agnode(g, "n"); m = agnode(g, "m"); e = agedge(g, n, m); /* Set an attribute - in this case one that affects the visible rendering */ agsafeset(n, "color", "red", ""); /* Compute a layout using layout engine from command line args */ gvLayoutJobs(gvc, g); /* Write the graph according to -T and -o options */ gvRenderJobs(gvc, g); /* Free layout data */ gvFreeLayout(gvc, g); /* Free graph structures */ agclose(g); /* close output file, free context, and return number of errors */ return (gvFreeContext(gvc)); }
static void intr(int s) { if (G) gvRenderJobs(Gvc, G); exit (gvFreeContext(Gvc)); }
SBML_ODESOLVER_API int drawJacoby(cvodeData_t *data, char *file, char *format) { #if !USE_GRAPHVIZ SolverError_error( WARNING_ERROR_TYPE, SOLVER_ERROR_NO_GRAPHVIZ, "odeSolver has been compiled without GRAPHIZ functionality. ", "Graphs are printed to stdout in the graphviz' .dot format."); drawJacobyTxt(data, file); #else int i, j; GVC_t *gvc; Agraph_t *g; Agnode_t *r; Agnode_t *s; Agedge_t *e; Agsym_t *a; char name[WORDSIZE]; char label[WORDSIZE]; char *output[3]; char *command = "dot"; char *formatopt; char *outfile; /* setting name of outfile */ ASSIGN_NEW_MEMORY_BLOCK(outfile, strlen(file)+ strlen(format)+7, char, 0); sprintf(outfile, "-o%s_jm.%s", file, format); /* setting output format */ ASSIGN_NEW_MEMORY_BLOCK(formatopt, strlen(format)+3, char, 0); sprintf(formatopt, "-T%s", format); /* construct command-line */ output[0] = command; output[1] = formatopt; output[2] = outfile; output[3] = NULL; /* set up renderer context */ gvc = (GVC_t *) gvContext(); #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION < 4 dotneato_initialize(gvc, 3, output); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 parse_args(gvc, 3, output); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvParseArgs(gvc, 3, output); #endif g = agopen("G", AGDIGRAPH); /* avoid overlapping nodes, for graph embedding by neato */ a = agraphattr(g, "overlap", ""); agxset(g, a->index, "scale"); /* set graph label */ if ( Model_isSetName(data->model->m) ) sprintf(label, "%s at time %g", Model_getName(data->model->m), data->currenttime); else if ( Model_isSetId(data->model->m) ) sprintf(label, "%s at time %g", Model_getId(data->model->m), data->currenttime); else sprintf(label, "label=\"at time %g\";\n", data->currenttime); a = agraphattr(g, "label", ""); agxset(g, a->index, label); /* Set edges from species A to species B if the corresponding entry in the jacobian ((d[B]/dt)/d[A]) is not '0'. Set edge color 'red' and arrowhead 'tee' if negative. */ for ( i=0; i<data->model->neq; i++ ) { for ( j=0; j<data->model->neq; j++ ) { if ( evaluateAST(data->model->jacob[i][j], data) != 0 ) { sprintf(name, "%s", data->model->names[j]); r = agnode(g,name); agset(r, "label", data->model->names[j]); sprintf(label, "%s.htm", data->model->names[j]); a = agnodeattr(g, "URL", ""); agxset(r, a->index, label); sprintf(name,"%s", data->model->names[i]); s = agnode(g,name); agset(s, "label", data->model->names[i]); sprintf(label, "%s.htm", data->model->names[i]); a = agnodeattr(g, "URL", ""); agxset(s, a->index, label); e = agedge(g,r,s); a = agedgeattr(g, "label", ""); sprintf(name, "%g", evaluateAST(data->model->jacob[i][j], data)); agxset (e, a->index, name); if ( evaluateAST(data->model->jacob[i][j], data) < 0 ) { a = agedgeattr(g, "arrowhead", ""); agxset(e, a->index, "tee"); a = agedgeattr(g, "color", ""); agxset(e, a->index, "red"); } } } } /* Compute a layout */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 gvBindContext(gvc, g); dot_layout(g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 gvlayout_layout(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvLayoutJobs(gvc, g); #endif /* Write the graph according to -T and -o options */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dotneato_write(gvc); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 emit_jobs(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvRenderJobs(gvc, g); #endif /* Clean out layout data */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dot_cleanup(g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 gvlayout_cleanup(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvFreeLayout(gvc, g); #endif /* Free graph structures */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dot_cleanup(g); #endif agclose(g); /* Clean up output file and errors */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 gvFREEcontext(gvc); dotneato_eof(gvc); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 dotneato_terminate(gvc); #elif (GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6) || GRAPHVIZ_MAJOR_VERSION >= 3 gvFreeContext(gvc); #endif xfree(formatopt); xfree(outfile); #endif return 1; }
SBML_ODESOLVER_API int drawModel(Model_t *m, char* file, char *format) { #if !USE_GRAPHVIZ SolverError_error( WARNING_ERROR_TYPE, SOLVER_ERROR_NO_GRAPHVIZ, "odeSolver has been compiled without GRAPHIZ functionality. ", "Graphs are printed to stdout in the graphviz' .dot format."); drawModelTxt(m, file); #else GVC_t *gvc; Agraph_t *g; Agnode_t *r; Agnode_t *s; Agedge_t *e; Agsym_t *a; Species_t *sp; Reaction_t *re; const ASTNode_t *math; SpeciesReference_t *sref; ModifierSpeciesReference_t *mref; char *output[4]; char *command = "dot"; char *formatopt; char *outfile; int i,j; int reversible; char name[WORDSIZE]; char label[WORDSIZE]; /* setting name of outfile */ ASSIGN_NEW_MEMORY_BLOCK(outfile, strlen(file)+ strlen(format)+7, char, 0); sprintf(outfile, "-o%s_rn.%s", file, format); /* setting output format */ ASSIGN_NEW_MEMORY_BLOCK(formatopt, strlen(format)+3, char, 0); sprintf(formatopt, "-T%s", format); /* construct command-line */ output[0] = command; output[1] = formatopt; output[2] = outfile; output[3] = NULL; /* set up renderer context */ gvc = (GVC_t *) gvContext(); #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION < 4 dotneato_initialize(gvc, 3, output); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 parse_args(gvc, 3, output); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvParseArgs(gvc, 3, output); #endif g = agopen("G", AGDIGRAPH); /* avoid overlapping nodes, for graph embedding by neato */ a = agraphattr(g, "overlap", ""); agxset(g, a->index, "scale"); for ( i=0; i<Model_getNumReactions(m); i++ ) { re = Model_getReaction(m,i); reversible = Reaction_getReversible(re); sprintf(name, "%s", Reaction_getId(re)); r = agnode(g,name); a = agnodeattr(g, "shape", "ellipse"); agxset(r, a->index, "box"); sprintf(label, "%s", Reaction_isSetName(re) ? Reaction_getName(re) : Reaction_getId(re)); agset(r, "label", label); sprintf(label, "%s.htm", Reaction_getId(re)); a = agnodeattr(g, "URL", ""); agxset(r, a->index, label); for ( j=0; j<Reaction_getNumModifiers(re); j++ ) { mref = Reaction_getModifier(re,j); sp = Model_getSpeciesById(m, ModifierSpeciesReference_getSpecies(mref)); sprintf(name,"%s", Species_getId(sp)); s = agnode(g,name); sprintf(label, "%s", Species_isSetName(sp) ? Species_getName(sp) : Species_getId(sp)); agset(s, "label", label); if ( Species_getBoundaryCondition(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "blue"); } if ( Species_getConstant(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "green4"); } sprintf(label, "%s.htm", Species_getId(sp)); a = agnodeattr(g, "URL", ""); agxset(s, a->index, label); e = agedge(g,s,r); a = agedgeattr(g, "style", ""); agxset(e, a->index, "dashed"); a = agedgeattr(g, "arrowhead", ""); agxset(e, a->index, "odot"); } for ( j=0; j<Reaction_getNumReactants(re); j++ ) { sref = Reaction_getReactant(re,j); sp = Model_getSpeciesById(m, SpeciesReference_getSpecies(sref)); sprintf(name,"%s", Species_getId(sp)); s = agnode(g, name); sprintf(label, "%s", Species_isSetName(sp) ? Species_getName(sp) : Species_getId(sp)); agset(s, "label", label); if ( Species_getBoundaryCondition(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "blue"); } if ( Species_getConstant(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "green4"); } sprintf(label, "%s.htm", Species_getId(sp)); a = agnodeattr(g, "URL", ""); agxset(s, a->index, label); e = agedge(g,s,r); a = agedgeattr(g, "label", ""); if ( (SpeciesReference_isSetStoichiometryMath(sref)) ) { math = SpeciesReference_getStoichiometryMath(sref); if ( (strcmp(SBML_formulaToString(math),"1") != 0) ) { agxset (e, a->index, SBML_formulaToString(math)); } } else { if ( SpeciesReference_getStoichiometry(sref) != 1 ) { sprintf(name, "%g", SpeciesReference_getStoichiometry(sref)); agxset (e, a->index, name); } } if ( reversible == 1 ) { a = agedgeattr(g, "arrowtail", ""); agxset(e, a->index, "onormal"); } } for ( j=0; j<Reaction_getNumProducts(re); j++ ) { sref = Reaction_getProduct(re,j); sp = Model_getSpeciesById(m, SpeciesReference_getSpecies(sref)); sprintf(name,"%s", Species_getId(sp)); s = agnode(g,name); sprintf(label, "%s", Species_isSetName(sp) ? Species_getName(sp) : Species_getId(sp)); agset(s, "label", label); if ( Species_getBoundaryCondition(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "blue"); } if ( Species_getConstant(sp) ) { a = agnodeattr(g, "color", ""); agxset(s, a->index, "green4"); } sprintf(label, "%s.htm", Species_getId(sp)); a = agnodeattr(g, "URL", ""); agxset(s, a->index, label); e = agedge(g,r,s); a = agedgeattr(g, "label", ""); if ( SpeciesReference_isSetStoichiometryMath(sref) ) { math = SpeciesReference_getStoichiometryMath(sref); if ( (strcmp(SBML_formulaToString(math),"1") != 0) ) { agxset (e, a->index, SBML_formulaToString(math)); } } else { if ( SpeciesReference_getStoichiometry(sref) != 1 ) { sprintf(name, "%g",SpeciesReference_getStoichiometry(sref)); agxset (e, a->index,name); } } if ( reversible == 1 ) { a = agedgeattr(g, "arrowtail", ""); agxset(e, a->index, "onormal"); } } } /* Compute a layout */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 gvBindContext(gvc, g); dot_layout(g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 gvlayout_layout(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvLayoutJobs(gvc, g); #endif /* Write the graph according to -T and -o options */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dotneato_write(gvc); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 emit_jobs(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvRenderJobs(gvc, g); #endif /* Clean out layout data */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dot_cleanup(g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 gvlayout_cleanup(gvc, g); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvFreeLayout(gvc, g); #endif /* Free graph structures */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 dot_cleanup(g); #else agclose(g); #endif /* Clean up output file and errors */ #if GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION <= 2 gvFREEcontext(gvc); dotneato_eof(gvc); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION == 4 dotneato_terminate(gvc); #elif GRAPHVIZ_MAJOR_VERSION == 2 && GRAPHVIZ_MINOR_VERSION >= 6 || GRAPHVIZ_MAJOR_VERSION >= 3 gvFreeContext(gvc); #endif xfree(formatopt); xfree(outfile); #endif return 1; }
/* * Print in Graphviz format */ void FA_dump_dot_fn(struct FA *fa, const char *ofname, int inc_step) { struct FA_State *st_from = NULL; struct FA_State *st_to = NULL; struct FA_State *st = NULL; GVC_t *gvc = NULL; graph_t *g = NULL; Agedge_t *e = NULL; Agnode_t *e_from = NULL; Agnode_t *e_to = NULL; Agnode_t *state0 = NULL; Agnode_t **nodes = NULL; Agnode_t *node = NULL; char *argv[4] = { NULL }; char buf[4096]; int argc; int i; int ri, ci, ai; FA_ASSERT(fa); ASSERT(ofname != NULL); ASSERT(inc_step == FA_INSERT_EXT || inc_step == FA_INSERT_NOTHING); memset(buf, 0, sizeof(buf)); if (inc_step == FA_INSERT_EXT) (void)snprintf(buf, sizeof(buf) - 1, "-o%s.%d", ofname, fa->simstep); else (void)snprintf(buf, sizeof(buf) - 1, "-o%s", ofname); argv[0] = strdup("FLViz.exe"); argv[1] = strdup(buf); argv[2] = strdup("-Tsvg"); argv[3] = NULL; argc = (sizeof(argv) / sizeof(argv[0])) - 1; gvc = gvContext(); ASSERT(gvc != NULL); gvParseArgs(gvc, argc, argv); memset(buf, 0, sizeof(buf)); snprintf(buf, sizeof(buf) - 1, "flvizstep%d", fa->simstep); g = agopen(buf, AGDIGRAPHSTRICT); /* Ustawianie atrybutów dla grafu */ agraphattr(g, "size", "8,8"); agraphattr(g, "rankdir", "LR"); /* Stan 0 */ state0 = agnode(g, "state0"); agsafeset(state0, "label", "", ""); agsafeset(state0, "width", "0.1", ""); agsafeset(state0, "height", "0.1", ""); agsafeset(state0, "shape", "box", ""); agsafeset(state0, "style", "filled", ""); agsafeset(state0, "fillcolor", "white", ""); agsafeset(state0, "color", "white", ""); nodes = (Agnode_t **)calloc(sizeof(Agnode_t *), fa->nstates); ASSERT(nodes != NULL); for (i = 0; i < fa->nstates; i++) { st = &fa->states[i]; node = agnode(g, st->name); agsafeset(node, "label", st->name, ""); agsafeset(node, "width", "0.5", ""); agsafeset(node, "height", "0.5", ""); agsafeset(node, "shape", "circle", ""); if (st->flag & FA_STATE_LAST) agsafeset(node, "shape", "doublecircle", ""); agsafeset(node, "style", "filled", ""); agsafeset(node, "fillcolor", "gray", ""); if (st->flag & FA_STATE_CURR) agsafeset(node, "fillcolor", "green", ""); st->obj = node; nodes[i] = node; } e = agedge(g, state0, (Agnode_t *)fa->states[0].obj); agsafeset(e, "label", "START", ""); if (fa->trans_from == fa->state0 && fa->trans_to == &fa->states[0]) agsafeset(e, "color", "green", ""); for (ri = 0; ri < fa->nstates; ri++) { st_from = fa->transt[ri][0]; e_from = (Agnode_t *)st_from->obj; for (ai = 0; ai < fa->nalpha; ai++) { ci = ai + 1; st_to = fa->transt[ri][ci]; if (st_to == NULL) continue; e_to = (Agnode_t *)st_to->obj; e = agedge(g, e_from, e_to); agsafeset(e, "label", fa->alpha[ai].word, ""); if (fa->trans_from == st_from && fa->trans_to == st_to) agsafeset(e, "color", "green", ""); } } /* Compute a layout using layout engine from command line args */ gvLayoutJobs(gvc, g); /* Write the graph according to -T and -o options */ gvRenderJobs(gvc, g); gvFreeLayout(gvc, g); agclose(g); gvFreeContext(gvc); fa->simstep++; }