34static double distvec(
double *p0,
double *p1,
double *vec)
39 for (k = 0; k <
Ndim; k++) {
40 vec[k] = p0[k] - p1[k];
41 dist += vec[k] * vec[k];
51 double **rv =
gv_calloc(m,
sizeof(
double*));
52 double *mem =
gv_calloc(m * n,
sizeof(
double));
53 for (i = 0; i < m; i++) {
56 for (j = 0; j < n; j++)
71static double ***
new_3array(
int m,
int n,
int p,
double ival)
75 double ***rv =
gv_calloc(m + 1,
sizeof(
double**));
76 for (i = 0; i < m; i++) {
77 rv[i] =
gv_calloc(n + 1,
sizeof(
double*));
78 for (j = 0; j < n; j++) {
80 for (k = 0; k < p; k++)
94 for (i = 0; rv[i]; i++) {
95 for (j = 0; rv[i][j]; j++)
116 if (*
s ==
'\0')
return 1;
118 if (sscanf(
s,
"%lf", val) < 1 || *val < 0 || (*val == 0 && !
Nop)) {
180 }
else if (deg == 1) {
195 double total_len = 0.0;
221 double total_len = 0.0;
222 double dfltlen = 1.0;
226 fprintf(stderr,
"Scanning graph %s, %d nodes\n",
agnameof(
G),
237 }
else if (deg == 1) {
284 Initial_dist = total_len / (nE > 0 ? nE : 1) * sqrt(nV) + 1;
316 for (k = n; k <
Ndim; k++)
340 fprintf(stderr,
"Setting initial positions\n");
346 agwarningf(
"start=0 not supported with mode=self - ignored\n");
365 fprintf(stderr,
"Setting up spring model: ");
371 for (i = 0; i < nG; i++) {
372 for (j = 0; j < i; j++) {
376 K[i][j] = K[j][i] = f;
381 for (i = 0; i < nG; i++)
382 for (k = 0; k <
Ndim; k++)
386 for (j = 0; j < nG; j++) {
391 for (k = 0; k <
Ndim; k++) {
416 for (i = 0; i < nG - 1; i++) {
418 for (j = i + 1; j < nG; j++) {
420 for (t0 = 0.0, d = 0; d <
Ndim; d++) {
426 - 2.0 *
GD_dist(
G)[i][j] * sqrt(t0));
442 fprintf(stderr,
"\nfinal e = %f",
total_e(
G, nG));
443 fprintf(stderr,
" %d%s iterations %.2f sec\n",
448 agwarningf(
"Max. iterations (%d) reached on graph %s\n",
459 for (k = 0; k <
Ndim; k++)
461 for (j = 0; j < nG; j++) {
466 for (k = 0; k <
Ndim; k++) {
467 old =
GD_t(
G)[i][j][k];
472 old =
GD_t(
G)[j][i][k];
479#define Msub(i,j) M[(i)*Ndim+(j)]
489 for (l = 0; l <
Ndim; l++)
490 for (k = 0; k <
Ndim; k++)
492 for (i = 0; i < nG; i++) {
497 for (k = 0; k <
Ndim; k++) {
502 for (k = 0; k <
Ndim; k++) {
503 for (l = 0; l < k; l++)
504 Msub(l, k) += K[n][i] *
D[n][i] * t[k] * t[l] *
scale;
506 K[n][i] * (1.0 -
D[n][i] * (sq - t[k] * t[k]) *
scale);
509 for (k = 1; k <
Ndim; k++)
510 for (l = 0; l < k; l++)
526 for (i = 0; i < nG; i++) {
530 for (m = 0.0, k = 0; k <
Ndim; k++)
542 fprintf(stderr,
"%.3f ", sqrt(max));
544 fprintf(stderr,
"\n");
559 for (i = 0; i <
Ndim; i++)
562 for (i = 0; i <
Ndim; i++) {
570 for (i = 0; i <
Ndim; i++) {
574 fprintf(stderr,
"%s %.3f\n",
agnameof(n), sum);
660 fprintf(stderr,
"Calculating shortest paths: ");
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static void del(Dict_t *d, Dtlink_t **set, Agedge_t *e)
static void init(int argc, char *argv[], double *angle, double *accuracy, int *check_edges_with_same_endpoint, int *seed, const char **color_scheme, int *lightness)
static double dist(int dim, double *x, double *y)
static pointf scale(double c, pointf p)
static double len(glCompPoint p)
static int cnt(Dict_t *d, Dtlink_t **set)
int agnedges(Agraph_t *g)
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
char * agget(void *obj, char *name)
char * agxget(void *obj, Agsym_t *sym)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
#define agfindedge(g, t, h)
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)
void agwarningf(const char *fmt,...)
int agerr(agerrlevel_t level, const char *fmt,...)
#define GD_neato_nlist(g)
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.
int agdelete(Agraph_t *g, void *obj)
deletes object. Equivalent to agclose, agdelnode, and agdeledge for obj being a graph,...
textitem scanner parser str
int checkStart(graph_t *G, int nG, int dflt)
NEATOPROCS_API void solve(double *, double *, double *, size_t)
static void heapup(node_t *v)
static void update_arrays(graph_t *G, int nG, int i)
static void make_spring(graph_t *, Agnode_t *, Agnode_t *, double)
void solve_model(graph_t *G, int nG)
void randompos(node_t *np, int nG)
int scan_graph(graph_t *g)
void s1(graph_t *G, node_t *node)
void jitter3d(node_t *np, int nG)
void shortest_path(graph_t *G, int nG)
static node_t * prune(graph_t *G, node_t *np, node_t *next)
static void D2E(graph_t *G, int nG, int n, double *M)
static double setEdgeLen(graph_t *G, node_t *np, Agsym_t *lenx, double dfltlen)
node_t * neato_dequeue(void)
void jitter_d(node_t *np, int nG, int n)
int scan_graph_mode(graph_t *G, int mode)
void free_array(double **rv)
void free_scan_graph(graph_t *g)
void diffeq_model(graph_t *G, int nG)
static void move_node(graph_t *, int, Agnode_t *)
void initial_positions(graph_t *G, int nG)
static Agnode_t * choose_node(graph_t *, int)
static int degreeKind(graph_t *g, node_t *n, node_t **op)
static void heapdown(node_t *v)
static void free_3array(double ***rv)
static double total_e(graph_t *G, int nG)
static double fpow32(double x)
void neato_enqueue(node_t *v)
static double distvec(double *p0, double *p1, double *vec)
static double *** new_3array(int m, int n, int p, double ival)
static int lenattr(edge_t *e, Agsym_t *index, double *val)
double ** new_array(int m, int n, double ival)