X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=graph.c;h=a81de42e89e2bb3839ccf2517c25af38b30f1b9d;hb=5cb1a1aa2036ff015feafa61691c9dfde9fa4395;hp=f0ce19db99fe08a1d2a0d82ab2f1746db1bae483;hpb=7968bc4aca3306473e7ab0a55d4bdc721a3eacd5;p=moebius2.git diff --git a/graph.c b/graph.c index f0ce19d..a81de42 100644 --- a/graph.c +++ b/graph.c @@ -4,6 +4,7 @@ #include "mgraph.h" #include "minimise.h" +#include "parallel.h" static int sqdistances[N][N]; @@ -14,7 +15,7 @@ static void breadth_first_search(int start, int sqdistances_r[N]) { int v,e, current, future, dfuture; buf_push= buf_pop= buffer; - FOR_VERTEX(v) d[v]= -1; + FOR_VERTEX(v,INNER) d[v]= -1; d[start]= 0; *buf_push++= start; @@ -31,7 +32,7 @@ static void breadth_first_search(int start, int sqdistances_r[N]) { assert(buf_pop==buf_push); assert(buf_push <= buffer+sizeof(buffer)/sizeof(buffer[0])); - FOR_VERTEX(v) { + FOR_VERTEX(v,INNER) { assert(d[v] >= 0); sqdistances_r[v]= d[v] * d[v]; } @@ -40,10 +41,10 @@ static void breadth_first_search(int start, int sqdistances_r[N]) { // } -void graph_layout_prepare() { +void graph_layout_prepare(void) { int v1; - FOR_VERTEX(v1) + FOR_VERTEX(v1,INNER) breadth_first_search(v1, sqdistances[v1]); alpha= 2; @@ -53,7 +54,7 @@ void graph_layout_prepare() { } -double graph_layout_cost(const Vertices v) { +double graph_layout_cost(const Vertices v, int section) { /* For each (vi,vj) computes shortest path s_ij = |vi..vj| * along edges, and actual distance d_ij = |vi-vj|. * @@ -76,7 +77,7 @@ double graph_layout_cost(const Vertices v) { int v1,v2,e, nedges=0; double totaledgelength=0, meanedgelength, meanedgelength2; - FOR_EDGE(v1,e,v2) { + FOR_EDGE(v1,e,v2,INNER) { totaledgelength += hypotD(v[v1], v[v2]); nedges++; } @@ -85,8 +86,8 @@ double graph_layout_cost(const Vertices v) { meanedgelength2= meanedgelength * meanedgelength; // printf("mean=%g mean^2=%g\n", meanedgelength, meanedgelength2); - FOR_VERTEX(v1) { - FOR_VERTEX(v2) { + FOR_VERTEX(v1,OUTER) { + FOR_VERTEX(v2,INNER) { if (v1 == v2) continue; double d2= hypotD2(v[v1],v[v2]);