53 len = strtod (lens, &p);
54 if (
len < 0 || p == lens)
76#define getprev(n) (((nodedata_t*)((n)->base.data))->prev)
77#define setprev(n,p) (((nodedata_t*)((n)->base.data))->prev = (p))
78#define isDone(n) (((nodedata_t*)((n)->base.data))->done)
79#define setDone(n) (((nodedata_t*)((n)->base.data))->done = true)
81static int cmpf(
void *key1,
void *key2) {
82 const double dist1 =
getdist(key1);
121 }
else if (newlen < oldlen) {
144 double maxdist = 0.0;
151 snprintf(dflt,
sizeof(dflt),
"%.3lf", HUGE_VAL);
157 snprintf(buf,
sizeof(buf),
"%.3lf",
dist);
173 oldmax = atof(
agxget(g, sym));
174 if (oldmax > maxdist)
177 snprintf(buf,
sizeof(buf),
"%.3lf", maxdist);
180 snprintf(buf,
sizeof(buf),
"%.3lf", maxdist);
215 "Usage: dijkstra [-ap?] <node> [<file> <node> <file>]\n\
216 -a - for nodes in a different component, set dist very large\n\
217 -d - use forward directed edges\n\
218 -p - attach shortest path info\n\
220If no files are specified, stdin is used\n";
228static void init(
int argc,
char *argv[])
234 while ((c = getopt(argc, argv,
"adp?")) != -1) {
246 if (optopt ==
'\0' || optopt ==
'?')
249 fprintf(stderr,
"%s: option -%c unrecognized\n",
262 fprintf(stderr,
"%s: no node specified\n",
CmdName);
267 for (j = i = 0; i < argc; i++) {
268 Nodes[j] = argv[i++];
269 Files[j] = argv[i] ? argv[i] :
"-";
293 fprintf(stderr,
"%s: no node %s in graph %s in %s\n",
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
CDT_API Dtmethod_t * Dtoset
ordered set (self-adjusting tree)
CDT_API Dt_t * dtopen(Dtdisc_t *, Dtmethod_t *)
abstract graph C library, Cgraph API
static NORETURN void graphviz_exit(int status)
static double dist(int dim, double *x, double *y)
static double len(glCompPoint p)
Agsym_t * agattrsym(void *obj, char *name)
looks up a string attribute for a graph object given as an argument
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
int agxset(void *obj, Agsym_t *sym, const char *value)
char * agxget(void *obj, Agsym_t *sym)
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 agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
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)
char * agnameof(void *)
returns a string descriptor for 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
void agclean(Agraph_t *g, int kind, char *rec_name)
calls agdelrec for all objects of the same class in an entire graph
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
PATHUTIL_API COORD dist2(Ppoint_t, Ppoint_t)
Agrec_t * data
stores programmer-defined data, access with AGDATA
implementation of Agrec_t
bool done
true if finished