void common_init_node(node_t * n) { struct fontinfo fi; char *str; ND_width(n) = late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH); ND_height(n) = late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEHEIGHT); ND_shape(n) = bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n); str = agxget(n, N_label); fi.fontsize = late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE); fi.fontname = late_nnstring(n, N_fontname, DEFAULT_FONTNAME); fi.fontcolor = late_nnstring(n, N_fontcolor, DEFAULT_COLOR); ND_label(n) = make_label((void*)n, str, ((aghtmlstr(str) ? LT_HTML : LT_NONE) | ( (shapeOf(n) == SH_RECORD) ? LT_RECD : LT_NONE)), fi.fontsize, fi.fontname, fi.fontcolor); if (N_xlabel && (str = agxget(n, N_xlabel)) && (str[0])) { ND_xlabel(n) = make_label((void*)n, str, (aghtmlstr(str) ? LT_HTML : LT_NONE), fi.fontsize, fi.fontname, fi.fontcolor); GD_has_labels(agraphof(n)) |= NODE_XLABEL; } ND_showboxes(n) = late_int(n, N_showboxes, 0, 0); ND_shape(n)->fns->initfn(n); }
void dot_sameports (graph_t* g) /* merge edge ports in G */ { node_t *n; edge_t *e; char *id; same_t same[MAXSAME]; int i; E_samehead = agfindattr(g->proto->e,"samehead"); E_sametail = agfindattr(g->proto->e,"sametail"); if (!(E_samehead || E_sametail)) return; for (n = agfstnode(g); n; n = agnxtnode(g,n)) { n_same = 0; for (e = agfstedge(g,n); e; e = agnxtedge(g,e,n)) { if (e->head==n && E_samehead && (id = agxget (e, E_samehead->index))[0]) sameedge (same, n, e, id); else if (e->tail==n && E_sametail && (id = agxget (e, E_sametail->index))[0]) sameedge (same, n, e, id); } for (i=0; i<n_same; i++) { if (same[i].l.size>1) sameport (n, &same[i].l, same[i].arr_len); free_list(same[i].l); /* I sure hope I don't need to free the char* id */ } } }
static int late_quadtree_scheme (graph_t* g, Agsym_t* sym, int dflt) { char* s; int v; int rv; if (!sym) return dflt; #ifdef WITH_CGRAPH s = agxget (g, sym); #else s = agxget (g, sym->index); #endif if (isdigit(*s)) { if ((v = atoi (s)) <= QUAD_TREE_FAST && v >= QUAD_TREE_NONE){ rv = v; } else { rv = dflt; } } else if (isalpha(*s)) { if (!strcasecmp(s, "none") || !strcasecmp(s, "false") ){ rv = QUAD_TREE_NONE; } else if (!strcasecmp(s, "normal") || !strcasecmp(s, "true") || !strcasecmp(s, "yes")){ rv = QUAD_TREE_NORMAL; } else if (!strcasecmp(s, "fast")){ rv = QUAD_TREE_FAST; } else { rv = dflt; } } else { rv = dflt; } return rv; }
static void write_diffattr(FILE * fp, int indent, void *obj, void *par, Agdict_t * dict) { Agsym_t *a; int i; char *p, *q; int cnt = 0; for (i = 0; i < dtsize(dict->dict); i++) { a = dict->list[i]; if (a->printed == FALSE) continue; p = agxget(obj, a->index); if (par) q = agxget(par, a->index); else q = a->value; if (strcmp(p, q)) { if (cnt++ == 0) { tabover(fp, indent); agputs(dict->name, fp); agputs(" [", fp); } else { agputs(",\n", fp); tabover(fp, indent + 1); } agputs(agcanonical(a->name), fp); agputc('=', fp); agputs(agcanonical(p), fp); } } if (cnt > 0) agputs("];\n", fp); }
static void write_diffattr(FILE * fp, int indent, void *obj, void *par, Agdict_t * dict) { Agsym_t *a; int i; char *p, *q; int cnt = 0; for (i = 0; i < dtsize(dict->dict); i++) { a = dict->list[i]; if (a->printed == FALSE) continue; p = agxget(obj, a->index); if (par) q = agxget(par, a->index); else q = a->value; if (strcmp(p, q)) { if (cnt++ == 0) { tabover(fp, indent); fprintf(fp, "%s [", dict->name); } else { fprintf(fp, ",\n"); tabover(fp, indent + 1); } fprintf(fp, "%s=", agcanonical(a->name)); fprintf(fp, "%s", agcanonical(p)); } } if (cnt > 0) fprintf(fp, "];\n"); }
int user_pos(attrsym_t * posptr, attrsym_t * pinptr, node_t * np, int nG) { double *pvec; char *p, c; double z; if (posptr == NULL) return FALSE; pvec = ND_pos(np); p = agxget(np, posptr->index); if (p[0]) { c = '\0'; if ((Ndim >= 3) && (sscanf(p, "%lf,%lf,%lf%c", pvec, pvec+1, pvec+2, &c) >= 3)){ ND_pinned(np) = P_SET; if (PSinputscale > 0.0) { int i; for (i = 0; i < Ndim; i++) pvec[i] = pvec[i] / PSinputscale; } if (Ndim > 3) jitter_d(np, nG, 3); if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr->index)))) ND_pinned(np) = P_PIN; return TRUE; } else if (sscanf(p, "%lf,%lf%c", pvec, pvec + 1, &c) >= 2) { ND_pinned(np) = P_SET; if (PSinputscale > 0.0) { int i; for (i = 0; i < Ndim; i++) pvec[i] = pvec[i] / PSinputscale; } if (Ndim > 2) { if (N_z && (p = agxget(np, N_z->index)) && (sscanf(p,"%lf",&z) == 1)) { if (PSinputscale > 0.0) { pvec[2] = z / PSinputscale; } else pvec[2] = z; jitter_d(np, nG, 3); } else jitter3d(np, nG); } if ((c == '!') || (pinptr && mapbool(agxget(np, pinptr->index)))) ND_pinned(np) = P_PIN; return TRUE; } else agerr(AGERR, "node %s, position %s, expected two doubles\n", np->name, p); } return FALSE; }
static void transform(Agraph_t * g) { Agnode_t *n; Agedge_t *e; char *str; Agsym_t *m_ix, *s_ix; int cnt, d; m_ix = bindedgeattr(g, "minlen"); s_ix = bindedgeattr(g, "style"); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { d = myindegree(n) + myoutdegree(n); if (d == 0) { if (ChainLimit < 1) continue; if (ChainNode) { e = agedge(g, ChainNode, n, "", TRUE); agxset(e, s_ix, "invis"); ChainSize++; if (ChainSize < ChainLimit) ChainNode = n; else { ChainNode = NULL; ChainSize = 0; } } else ChainNode = n; } else if (d > 1) { if (MaxMinlen < 1) continue; cnt = 0; for (e = agfstin(g, n); e; e = agnxtin(g, e)) { if (isleaf(agtail(e))) { str = agxget(e, m_ix); if (str[0] == 0) { adjustlen(e, m_ix, (cnt % MaxMinlen) + 1); cnt++; } } } cnt = 0; for (e = agfstout(g, n); e; e = agnxtout(g, e)) { if (isleaf(e->node) || (Do_fans && ischainnode(e->node))) { str = agxget(e, m_ix); if (str[0] == 0) adjustlen(e, m_ix, (cnt % MaxMinlen) + 1); cnt++; } } } } }
static void addRevEdge(Agraph_t * g, Agedge_t * e) { Agsym_t* sym; Agedge_t* f = agedge (g, aghead(e), agtail(e), agnameof(e), 1); agcopyattr (; sym = agattr (g, AGEDGE, TAILPORT_ID, 0); if (sym) agsafeset (f, HEADPORT_ID, agxget (e, sym), ""); sym = agattr (g, AGEDGE, HEADPORT_ID, 0); if (sym) agsafeset (f, TAILPORT_ID, agxget (e, sym), ""); }
static int late_smooth (graph_t* g, Agsym_t* sym, int dflt) { char* s; int v; int rv; if (!sym) return dflt; #ifdef WITH_CGRAPH s = agxget (g, sym); #else s = agxget (g, sym->index); #endif if (isdigit(*s)) { #if (HAVE_GTS || HAVE_TRIANGLE) if ((v = atoi (s)) <= SMOOTHING_RNG) #else if ((v = atoi (s)) <= SMOOTHING_SPRING) #endif rv = v; else rv = dflt; } else if (isalpha(*s)) { if (!strcasecmp(s, "avg_dist")) rv = SMOOTHING_STRESS_MAJORIZATION_AVG_DIST; else if (!strcasecmp(s, "graph_dist")) rv = SMOOTHING_STRESS_MAJORIZATION_GRAPH_DIST; else if (!strcasecmp(s, "none")) rv = SMOOTHING_NONE; else if (!strcasecmp(s, "power_dist")) rv = SMOOTHING_STRESS_MAJORIZATION_POWER_DIST; #if (HAVE_GTS || HAVE_TRIANGLE) else if (!strcasecmp(s, "rng")) rv = SMOOTHING_RNG; #endif else if (!strcasecmp(s, "spring")) rv = SMOOTHING_SPRING; #if (HAVE_GTS || HAVE_TRIANGLE) else if (!strcasecmp(s, "triangle")) rv = SMOOTHING_TRIANGLE; #endif else rv = dflt; } else rv = dflt; return rv; }
boolean late_bool(void *obj, attrsym_t * attr, int def) { if (attr == NULL) return def; return mapbool(agxget(obj, attr)); }
/* mapN: * Convert cluster nodes back to ordinary nodes * If n is already ordinary, return it. * Otherwise, we know node's name is "__i:xxx" * where i is some number and xxx is the nodes's original name. * Create new node of name xxx if it doesn't exist and add n to clg * for later deletion. */ static node_t *mapN(node_t * n, graph_t * clg) { node_t *nn; char *name; graph_t *g = agraphof(n); Agsym_t *sym; if (!(IS_CLUST_NODE(n))) return n; agsubnode(clg, n, 1); name = strchr(agnameof(n), ':'); assert(name); name++; if ((nn = agfindnode(g, name))) return nn; nn = agnode(g, name, 1); agbindrec(nn, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); /* Set all attributes to default */ for (sym = agnxtattr(g, AGNODE, NULL); sym; (sym = agnxtattr(g, AGNODE, sym))) { if (agxget(nn, sym) != sym->defval) agxset(nn, sym, sym->defval); } return nn; }
/* copyAttr: * Copy attributes from src to tgt. Overrides currently * defined values. * FIX: we should probably use the default value of the source * graph when initializing the attribute, rather than "". * NOTE: We do not assume src and tgt have the same kind. */ int copyAttr(Agobj_t * src, Agobj_t * tgt) { Agraph_t *srcg; Agraph_t *tgtg; Agsym_t *sym = 0; Agsym_t *tsym = 0; int skind = AGTYPE(src); int tkind = AGTYPE(tgt); char* val; srcg = agraphof(src); tgtg = agraphof(tgt); while ((sym = agnxtattr(srcg, skind, sym))) { tsym = agattrsym(tgt, sym->name); if (!tsym) tsym = agattr(tgtg, tkind, sym->name, sym->defval); val = agxget(src, sym); if (aghtmlstr (val)) { val = agstrdup_html (tgtg, val); agxset(tgt, tsym, val); agstrfree (tgtg, val); } else agxset(tgt, tsym, val); } return 0; }
static void ptest_initNode(node_t * n) { char *str; ND_width(n) = late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH); ND_height(n) = late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEWIDTH); if (N_label == NULL) str = NODENAME_ESC; else str = agxget(n, N_label->index); str = strdup_and_subst(str, NODENAME_ESC, n->name); ND_label(n) = make_label(str, late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE), late_nnstring(n, N_fontname, DEFAULT_FONTNAME), late_nnstring(n, N_fontcolor, DEFAULT_COLOR), n->graph); ND_shape(n) = bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE)); ND_shape(n)->initfn(n); /* ### need to quantize ? */ ptest_nodesize(n, n->GD_flip(graph)); }
static point *user_spline(attrsym_t * symptr, edge_t * e, int *np) { char *pos; int i, n, nc; point *ps = 0; point *pp; double x, y; if (symptr == NULL) return 0; pos = agxget(e, symptr->index); if (*pos == '\0') return 0; n = numFields(pos); *np = n; if (n > 1) { ps = ALLOC(n, 0, point); pp = ps; while (n) { i = sscanf(pos, "%lf,%lf%n", &x, &y, &nc); if (i < 2) { free(ps); ps = 0; break; } pos = pos + nc; pp->x = (int) x; pp->y = (int) y; pp++; n--; } } return ps; }
/* mapN: * Convert cluster nodes back to ordinary nodes * If n is already ordinary, return it. * Otherwise, we know node's name is "__i:xxx" * where i is some number and xxx is the nodes's original name. * Create new node of name xxx if it doesn't exist and add n to clg * for later deletion. */ static node_t *mapN(node_t * n, graph_t * clg) { extern Agdict_t *agdictof(void *); node_t *nn; char *name; graph_t *g = n->graph; Agdict_t *d; Agsym_t **list; Agsym_t *sym; if (!(IS_CLUST_NODE(n))) return n; aginsert(clg, n); name = strchr(n->name, ':'); assert(name); name++; if ((nn = agfindnode(g, name))) return nn; nn = agnode(g, name); /* Set all attributes to default */ d = agdictof(n); list = d->list; while ((sym = *list++)) { /* Can use pointer comparison because of ref strings. */ if (agxget(nn, sym->index) != sym->value) agxset(nn, sym->index, sym->value); } return nn; }
void GraphEdge::updateWithEdge(edge_t* edge) { kDebug(); DotRenderOpVec ops; // decrease mem peak setRenderOperations(ops); if (agget(edge, (char*)"_draw_") != NULL) { parse_renderop(agget(edge, (char*)"_draw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } if (agget(edge, (char*)"_ldraw_") != NULL) { parse_renderop(agget(edge, (char*)"_ldraw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } if (agget(edge, (char*)"_hdraw_") != NULL) { parse_renderop(agget(edge, (char*)"_hdraw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } if (agget(edge, (char*)"_tdraw_") != NULL) { parse_renderop(agget(edge, (char*)"_tdraw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } if (agget(edge, (char*)"_hldraw_") != NULL) { parse_renderop(agget(edge, (char*)"_hldraw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } if (agget(edge, (char*)"_tldraw_") != NULL) { parse_renderop(agget(edge, (char*)"_tldraw_"), ops); kDebug() << "element renderOperations size is now " << ops.size(); } setRenderOperations(ops); Agsym_t *attr = agnxtattr(agraphof(agtail(edge)), AGEDGE, NULL); while(attr) { kDebug() /*<< edge->name*/ << ":" << attr->name << agxget(edge,attr); m_attributes[attr->name] = agxget(edge,attr); attr = agnxtattr(agraphof(agtail(edge)), AGEDGE, attr); } }
int nonconstraint_edge(edge_t * e) { char *constr; #ifndef WITH_CGRAPH if (E_constr && (constr = agxget(e, E_constr->index))) { #else /* WITH_CGRAPH */ if (E_constr && (constr = agxget(e, E_constr))) { #endif /* WITH_CGRAPH */ if (constr[0] && mapbool(constr) == FALSE) return TRUE; } return FALSE; } static void interclust1(graph_t * g, node_t * t, node_t * h, edge_t * e) { node_t *v, *t0, *h0; int offset, t_len, h_len, t_rank, h_rank; edge_t *rt, *rh; if (ND_clust(agtail(e))) t_rank = ND_rank(agtail(e)) - ND_rank(GD_leader(ND_clust(agtail(e)))); else t_rank = 0; if (ND_clust(aghead(e))) h_rank = ND_rank(aghead(e)) - ND_rank(GD_leader(ND_clust(aghead(e)))); else h_rank = 0; offset = ED_minlen(e) + t_rank - h_rank; if (offset > 0) { t_len = 0; h_len = offset; } else { t_len = -offset; h_len = 0; } v = virtual_node(g); ND_node_type(v) = SLACKNODE; t0 = UF_find(t); h0 = UF_find(h); rt = make_aux_edge(v, t0, t_len, CL_BACK * ED_weight(e)); rh = make_aux_edge(v, h0, h_len, ED_weight(e)); ED_to_orig(rt) = ED_to_orig(rh) = e; }
/* _write_plain: */ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) { int i, j, splinePoints; char *tport, *hport; node_t *n; edge_t *e; bezier bz; pointf pt; char *lbl; char* fillcolor; #ifdef WITH_CGRAPH putstr = g->clos->disc.io->putstr; #endif // setup_graph(job, g); setYInvert(g); pt = GD_bb(g).UR; printdouble(f, "graph ", job->zoom); printdouble(f, " ", PS2INCH(pt.x)); printdouble(f, " ", PS2INCH(pt.y)); agputc('\n', f); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { if (IS_CLUST_NODE(n)) continue; printstring(f, "node ", agcanonStr(agnameof(n))); printpoint(f, ND_coord(n)); if (ND_label(n)->html) /* if html, get original text */ #ifndef WITH_CGRAPH lbl = agcanonStr (agxget(n, N_label->index)); #else lbl = agcanonStr (agxget(n, N_label)); #endif else lbl = canon(agraphof(n),ND_label(n)->text); printdouble(f, " ", ND_width(n)); printdouble(f, " ", ND_height(n)); printstring(f, " ", lbl); printstring(f, " ", late_nnstring(n, N_style, "solid")); printstring(f, " ", ND_shape(n)->name); printstring(f, " ", late_nnstring(n, N_color, DEFAULT_COLOR)); fillcolor = late_nnstring(n, N_fillcolor, ""); if (fillcolor[0] == '\0') fillcolor = late_nnstring(n, N_color, DEFAULT_FILL); printstring(f, " ", fillcolor); agputc('\n', f); }
int nonconstraint_edge(edge_t* e) { char *constr; if (E_constr && (constr = agxget(e,E_constr->index))) { if (constr[0] && mapbool(constr) == FALSE) return TRUE; } return FALSE; }
double doubleattr(void *obj, int index, double defval) { double val; if (index < 0) return defval; if (sscanf(agxget(obj, index), "%lf", &val) < 1) return defval; return val; }
int late_int(void *obj, attrsym_t *attr, int def, int low) { char *p; int rv; if (attr == NULL) return def; p = agxget(obj,attr->index); if (p[0] == '\0') return def; if ((rv = atoi(p)) < low) rv = low; return rv; }
static void write_attrs(Agobj_t * obj, GVJ_t * job, state_t* sp) { Agraph_t* g = agroot(obj); int type = AGTYPE(obj); char* attrval; Agsym_t* sym = agnxtattr(g, type, NULL); if (!sym) return; for (; sym; sym = agnxtattr(g, type, sym)) { if (!(attrval = agxget(obj, sym))) continue; if ((*attrval == '\0') && !streq(sym->name, "label")) continue; gvputs(job, ",\n"); indent(job, sp->Level); gvprintf(job, "\"%s\": ", stoj(sym->name, sp)); if (sp->doXDot && isXDot(sym->name)) write_xdots(agxget(obj, sym), job, sp); else gvprintf(job, "\"%s\"", stoj(agxget(obj, sym), sp)); } }
double late_float(void *obj,attrsym_t *attr, double def, double low) { char *p; double rv; if (attr == NULL) return def; p = agxget(obj,attr->index); if (p[0] == '\0') return def; if ((rv = atof(p)) < low) rv = low; return rv; }
static void emitGraphAttrs (Agraph_t* G, FILE* outFile) { Agsym_t* s; char* v; for (s = agnxtattr (G, AGRAPH, NULL); s; s = agnxtattr (G, AGRAPH, s)) { if (*(v = agxget (G, s))) { emitAttr (s->name, v, outFile, 1); } } }
static double getlength(Agedge_t * e) { edgedata_t *data; data = (edgedata_t *) (e->base.data); if (data->length == 0) { if (len_sym) data->length = atof(agxget(e, len_sym)); if (data->length <= 0) data->length = 1.0; } return data->length; }
static void post(Agraph_t * g) { Agnode_t *v; Agnode_t *prev; char buf[256]; char dflt[256]; Agsym_t *sym; Agsym_t *psym; double dist, oldmax; double maxdist = 0.0; /* maximum "finite" distance */ sym = agattr(g, AGNODE, "dist", ""); if (doPath) psym = agattr(g, AGNODE, "prev", ""); if (setall) sprintf(dflt, "%.3lf", HUGE); for (v = agfstnode(g); v; v = agnxtnode(g, v)) { dist = getdist(v); if (dist) { dist--; sprintf(buf, "%.3lf", dist); agxset(v, sym, buf); if (doPath && (prev = getprev(v))) agxset(v, psym, agnameof(prev)); if (maxdist < dist) maxdist = dist; } else if (setall) agxset(v, sym, dflt); } sym = agattrsym(g, "maxdist"); if (sym) { if (!setall) { /* if we are preserving distances in other components, * check previous value of maxdist. */ oldmax = atof(agxget(g, sym)); if (oldmax > maxdist) maxdist = oldmax; } sprintf(buf, "%.3lf", maxdist); agxset(g, sym, buf); } else { sprintf(buf, "%.3lf", maxdist); agattr(g, AGRAPH, "maxdist", buf); } agclean(g, AGNODE, "dijkstra"); agclean(g, AGEDGE, "dijkstra"); }
/* noClip: * Return true if head/tail end of edge should not be clipped * to node. */ static bool noClip(edge_t *e, attrsym_t* sym) { char *str; bool rv = FALSE; if (sym) { /* mapbool isn't a good fit, because we want "" to mean TRUE */ str = agxget(e,sym->index); if (str && str[0]) rv = !mapbool(str); else rv = FALSE; } return rv; }
static void initPos(Agraph_t * g) { Agnode_t *n; Agedge_t *e; double *pvec; char *p; point *sp; int pn; attrsym_t *N_pos = agfindnodeattr(g, "pos"); attrsym_t *E_pos = agfindedgeattr(g, "pos"); assert(N_pos); if (!E_pos) { if (doEdges) fprintf(stderr, "Warning: turning off doEdges, graph %s\n", g->name); doEdges = 0; } for (n = agfstnode(g); n; n = agnxtnode(g, n)) { pvec = ND_pos(n); p = agxget(n, N_pos->index); if (p[0] && (sscanf(p, "%lf,%lf", pvec, pvec + 1) == 2)) { int i; for (i = 0; i < NDIM; i++) pvec[i] = pvec[i] / PSinputscale; } else { fprintf(stderr, "could not find pos for node %s in graph %s\n", n->name, g->name); exit(1); } ND_coord_i(n).x = POINTS(ND_pos(n)[0]); ND_coord_i(n).y = POINTS(ND_pos(n)[1]); } if (doEdges) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { if ((sp = user_spline(E_pos, e, &pn)) != 0) { clip_and_install(e, sp, pn); free(sp); } else { fprintf(stderr, "Missing edge pos for edge %s - %s in graph %s\n", n->name, e->head->name, g->name); exit(1); } } } } }
static int late_mode (graph_t* g, Agsym_t* sym, int dflt) { char* s; int v; int rv; if (!sym) return dflt; #ifdef WITH_CGRAPH s = agxget (g, sym); #else s = agxget (g, sym->index); #endif if (isdigit(*s)) { if ((v = atoi (s)) <= METHOD_UNIFORM_STRESS) rv = v; else rv = dflt; } else if (isalpha(*s)) { if (!strcasecmp(s, "spring")) rv = METHOD_SPRING_ELECTRICAL; else if (!strcasecmp(s, "maxent")) rv = METHOD_SPRING_MAXENT; else if (!strcasecmp(s, "stress")) rv = METHOD_STRESS; else if (!strcasecmp(s, "uniform")) rv = METHOD_UNIFORM_STRESS; else { agerr (AGWARN, "Unknown value \"%s\" for mode attribute\n", s); rv = dflt; } } else rv = dflt; return rv; }
static double getlength(Agedge_t * e) { double len; char* lens; char* p; if (len_sym && (*(lens = agxget(e, len_sym)))) { len = strtod (lens, &p); if ((len < 0) || (p == lens)) len = 1; } else len = 1; return len; }