int transpose_onerank(Agraph_t* g, int r, boolean reverse) { int i,c0,c1,rv; node_t *v,*w; rv = 0; GD_rank(g)[r].candidate = FALSE; for (i = leftmost(g,r); i < rightmost(g,r); i++) { v = GD_rank(g)[r].v[i]; w = GD_rank(g)[r].v[i+1]; assert (ND_order(v) < ND_order(w)); if (left2right(g,v,w)) continue; c0 = c1 = 0; if (r > GD_minrank(g)) { c0 += in_cross(v,w); c1 += in_cross(w,v); } if (r < GD_maxrank(g)) { c0 += out_cross(v,w); c1 += out_cross(w,v); } if ((c1 < c0) || ((c0 > 0) && reverse && (c1 == c0))) { exchange(g,v,w); rv += (c0 - c1); } } return rv; }
void status_machine_imp::moveable(int from,int to) { REQUIRE(in_here(from)); REQUIRE(in_here(to)); status_direct left2right(from,to); _moveable_directs.push_back(left2right); }
void ArrowPainter::paint(QPoint From, QPoint To, Arrow::Direction Dir) { from = From; to = To; if(Dir == Arrow::automatic) { if(abs(from.x()-to.x()) > abs(from.y()-to.y())) left2right(); else top2bottom(); } else { if(Dir == Arrow::horizontal) left2right(); else top2bottom(); } }
static void reorder(graph_t *g, int r, boolean reverse, boolean hasfixed) { boolean changed, muststay; node_t **vlist, **lp, **rp, **ep; int i; changed = FALSE; vlist = GD_rank(g)[r].v; ep = &vlist[rightmost(g,r)]; for (i = leftmost(g,r); i <= rightmost(g,r); i++) { lp = &vlist[leftmost(g,r)]; /* find leftmost node that can be compared */ while ((lp < ep) && (ND_sortweight(*lp) < 0)) lp++; if (lp >= ep) break; /* find the node that can be compared */ muststay = FALSE; for (rp = lp + 1; rp < ep; rp++) { if (left2right(g,*lp,*rp)) { muststay = TRUE; break; } if (ND_sortweight(*rp) >= 0) break; /* weight defined; it's comparable */ } if (rp >= ep) break; if (muststay == FALSE) { register int p1 = ND_sortweight(*lp); register int p2 = ND_sortweight(*rp); if ((p1 > p2) || ((p1 == p2) && (reverse))) { exchange(g,*lp,*rp); changed = TRUE; } } lp = rp; if ((hasfixed == FALSE) && (reverse == FALSE)) ep--; } if (changed) { GD_rank(g)[r].changed = TRUE; GD_rank(g)[r].crossing_cache.valid = FALSE; if (r > 0) GD_rank(g)[r-1].crossing_cache.valid = FALSE; if (r + 1 > GD_rank(g)[r+1].n) GD_rank(g)[r-1].crossing_cache.valid = FALSE; } }