Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29868

Re: Untangle node positions "logic problem"

Newsgroups comp.lang.javascript
Date 2016-03-09 12:40 -0800
References <9c01e4ae-f564-4d42-91cb-3c0c858edd7a@googlegroups.com> <33306987-a34c-4c89-bfec-b53b021af527@googlegroups.com>
Message-ID <1b4bed87-c220-45dd-874e-df113093da65@googlegroups.com> (permalink)
Subject Re: Untangle node positions "logic problem"
From jonas.thornvall@gmail.com

Show all headers | View raw


Den onsdag 9 mars 2016 kl. 21:00:16 UTC+1 skrev jonas.t...@gmail.com:
> Den onsdag 9 mars 2016 kl. 20:15:22 UTC+1 skrev jonas.t...@gmail.com:
> > My new idea to untangle the links is simply to swap theiry positions.
> > But there muste be something wrong with my logic.
> > 
> > The circle function will attempt draw out the *nodes* in circle from lowest node to higest.
> > 
> > 0 NODE Links-> 2,3
> > 1 NODE Links-> 3,4
> > 2 NODE Links-> 0,4
> > 3 NODE Links-> 0,1
> > 4 NODE Links-> 1,2
> > 
> > As you may guess the links come out criss crossed.
> > But i was thinking if node 0 draw it first link to node 2.
> > Then i can interchange the cordinates of node 2 and node 0+1 "that is i+1" to move node segment 2 next to i.
> > 
> > So now i have the tempnode in memory and that will have one link point back j=0;
> > And one link point forward. That link should be exchanged with i+1. Because we are in next round of loop. I think the logic is straightforward so i can't see why it is not working. Swap cordinates of random with i+1 it should work.
> > 
> > function untangle_links(){
> > 
> > j=0;
> > tempnode=0;
> >   for(var i=0;i<nodes.length-1;i++){
> >     tempnode=arr[tempnode].nodelinks[j];
> >     tempX=arr[tempnode].rposX;
> >     tempY=arr[tempnode].rposY;
> >     arr[tempnode].rposX=arr[i+1].rposX;
> >     arr[tempnode].rposY=arr[i+1].rposY;
> >     arr[i+1].rposX=tempX;
> >     arr[i+1].rposY=tempY;
> >     j=1;
> >   }
> > }
> 
> The principle seem sound but i think i need to make a list for what nodes that have been drawn to, that sure will be beneficial when there is more links than two at each node.

This is hairy todo

function untangle_links(){
var j=0;
var tempnodes=new Array();
tempnodes[k]=0;
tempnode=0;
  for(var i=0;i<nodes.length-1;i++){
    for(var k=0;k<tempnodes.length;k++){
       if (arr[tempnode].nodelinks[j]==tempnodes[k]) {j++;}
    }
    tempnodes[tempnodes.length+1]=arr[tempnode].nodelinks[j];
    tempnode=arr[tempnode].nodelinks[j];
    j=0;
    tempX=arr[tempnode].rposX;
    tempY=arr[tempnode].rposY;
    arr[tempnode].rposX=arr[i+1].rposX;
    arr[tempnode].rposY=arr[i+1].rposY;
    arr[i+1].rposX=tempX;
    arr[i+1].rposY=tempY;
  }
}

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 11:15 -0800
  Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 11:59 -0800
    Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 12:40 -0800
      Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 12:54 -0800
        Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 12:57 -0800
          Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 13:00 -0800
            Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 13:29 -0800
            Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 13:41 -0800
              Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 17:15 -0800
              Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 17:21 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-09 22:52 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-10 13:09 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 00:24 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 00:49 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 00:53 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 01:21 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 01:29 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 01:41 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-11 01:58 -0800
                Re: Untangle node positions "logic problem" jonas.thornvall@gmail.com - 2016-03-13 04:19 -0700
                Re: Untangle node positions "logic problem" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-13 17:22 +0100

csiph-web