41#define ND_relrank(n) (((Agnodeinfo_t*)((n)->base.data))->relrank)
42#define ND_x(n) (((Agnodeinfo_t*)((n)->base.data))->x)
56static int cmpf(
const void *x,
const void *y) {
61#pragma GCC diagnostic push
62#pragma GCC diagnostic ignored "-Wcast-qual"
67#pragma GCC diagnostic pop
71 if (relrank0 < relrank1)
73 if (relrank0 > relrank1)
81 if (sscanf(p,
"%lf %lf %lf", v, v + 1, v + 2) != 3 && p[0]) {
83 sscanf(
agxbuse(&buf),
"%lf %lf %lf", v, v + 1, v + 2);
90static char *
useString =
"Usage: gvcolor [-?] <files>\n\
92If no files are specified, stdin is used\n";
100static void init(
int argc,
char *argv[])
105 while ((c = getopt(argc, argv,
":?")) != -1) {
108 if (optopt ==
'\0' || optopt ==
'?')
111 fprintf(stderr,
"gvcolor: option -%c unrecognized\n",
117 fprintf(stderr,
"gvcolor: unexpected error\n");
134 double x, y, maxrank = 0.0;
135 double sum[
NC], d, lowsat, highsat;
139 "graph must be run through 'dot' before 'gvcolor'\n");
145 if ((p =
agget(g,
"Defcolor")))
148 if ((p =
agget(g,
"rankdir")) && p[0] ==
'L')
150 if ((p =
agget(g,
"flow")) && p[0] ==
'b')
152 if ((p =
agget(g,
"saturation"))) {
153 if (sscanf(p,
"%lf,%lf", &lowsat, &highsat) == 2) {
163 size_t nnodes = (size_t)nn;
168 if ((p =
agget(n,
"color")))
171 sscanf(p,
"%lf,%lf", &x, &y);
176 for (i = 0; i < nnodes; i++) {
183 for (i = 0; i < nnodes; i++) {
188 for (j = 0; j <
NC; j++)
189 if (
ND_x(n)[j] != 0.0)
194 for (j = 0; j <
NC; j++)
204 for (j = 0; j <
NC; j++) {
206 sum[j] +=
ND_x(v)[j];
213 for (j = 0; j <
NC; j++)
218 for (i = 0; i < nnodes; i++) {
225 for (j = 0; j <
NC; j++)
244 snprintf(buf,
sizeof(buf),
"%f %f %f", h,
s, b);
245 agset(n,
"color", buf);
static void agxbfree(agxbuf *xb)
free any malloced resources
static char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
abstract graph C library, Cgraph API
void colorxlate(char *str, agxbuf *buf)
static NORETURN void graphviz_exit(int status)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnnodes(Agraph_t *g)
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
int agset(void *obj, char *name, const char *value)
char * agget(void *obj, char *name)
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
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
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
static void init(int argc, char *argv[])
static int cmpf(const void *x, const void *y)
static void color(Agraph_t *g)
static void setcolor(char *p, double *v)
static const char * usage
Agraph_t * nextGraph(ingraph_state *sp)
ingraph_state * newIngraph(ingraph_state *sp, char **files)
supports user-supplied data
implementation of Agrec_t