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


Groups > comp.lang.javascript > #29895

Re: Untangle node positions "logic problem"

Newsgroups comp.lang.javascript
Date 2016-03-11 01:58 -0800
References (11 earlier) <6580e47f-d201-4f11-9a0f-fee5b007a00b@googlegroups.com> <1a254e78-4e61-41bc-a2c1-bfe97b0aa05e@googlegroups.com> <bc9fc91e-9198-4056-9eae-9ed17f220919@googlegroups.com> <58197b65-023c-4bf3-8aa7-50e6d679b920@googlegroups.com> <4bb8b3ef-ab56-48d8-97f7-d7f16528db8d@googlegroups.com>
Message-ID <aedc54e5-183e-44ef-bf2c-1b2b583bf66c@googlegroups.com> (permalink)
Subject Re: Untangle node positions "logic problem"
From jonas.thornvall@gmail.com

Show all headers | View raw


Den fredag 11 mars 2016 kl. 10:42:41 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 10:29:24 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 10:21:19 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 09:53:45 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 09:49:58 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 09:25:01 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den torsdag 10 mars 2016 kl. 22:10:04 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > Den torsdag 10 mars 2016 kl. 07:52:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > Den torsdag 10 mars 2016 kl. 02:21:54 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > > Den onsdag 9 mars 2016 kl. 22:41:33 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > > > Den onsdag 9 mars 2016 kl. 22:00:13 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > > > > Den onsdag 9 mars 2016 kl. 21:57:32 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > > > > > function untangle_links(){
> > > > > > > > > > > > var j=0;var tempnode=0;
> > > > > > > > > > > > var tnode=new Array();
> > > > > > > > > > > > tnode[k]=0;
> > > > > > > > > > > > 
> > > > > > > > > > > >   for(var i=0;i<nodes.length-1;i++){
> > > > > > > > > > > >     for(var k=0;k<tnode.length;k++){
> > > > > > > > > > > >        if (arr[tempnode].nodelinks[j]==tnode[k]) {j++;}
> > > > > > > > > > > >     }
> > > > > > > > > > > >     tempnode=arr[tempnode].nodelinks[j];
> > > > > > > > > > > >     tnode[tnode.length+1]=tempnode;
> > > > > > > > > > > >     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;
> > > > > > > > > > > >   }
> > > > > > > > > > > > }
> > > > > > > > > > > 
> > > > > > > > > > > This is an example where a stepwise turbo pascal debugger would do miracles.
> > > > > > > > > > > Because i would be able to find first link that goes wrong.
> > > > > > > > > > 
> > > > > > > > > > Or maybe i just missunderstood the draw circle function, well i should probably do one myself, but i thought it moved in degree steps for each node+
> > > > > > > > > 
> > > > > > > > > Welll there is certainly something wrong with the approach it swap back and forth. instead I will do a pure node sequense, store it in an array and fit the drawing program to follow it.
> > > > > > > > 
> > > > > > > > New approach work sometimes ;)
> > > > > > > > http://jt.node365.se/nodes17.html
> > > > > > > 
> > > > > > > Well the error lurking in the new function but since it so sporadice and cause the program to halt reset it is hard to catch the data that make it do so.
> > > > > > > 
> > > > > > > function untangle_links(arr)
> > > > > > > {
> > > > > > >    printnode = new Array;
> > > > > > >    var j = 0;
> > > > > > >    var tempnode = 0;
> > > > > > >    var tnode = new Array();
> > > > > > >    for(var i = 0; i < nodes; i ++ )
> > > > > > >    {
> > > > > > >       for(var k = 0; k < tnode.length; k ++ )
> > > > > > >       {
> > > > > > >            if (arr[tempnode].nodelinks[j] == tnode[k])
> > > > > > >          {
> > > > > > >             j ++ ;
> > > > > > >          }
> > > > > > >       }
> > > > > > >       tempnode = arr[tempnode].nodelinks[j];
> > > > > > >       tnode[tnode.length] = tempnode;
> > > > > > >       printnode[i] = tempnode;
> > > > > > >       j = 0;
> > > > > > >    }
> > > > > > >    return printnode;
> > > > > > > }
> > > > > > 
> > > > > > Well i tried with 6 nodes manually from a generated setup with x and y cordinates, and now i can see what goes wrong. If next node actually correct the function stalls and just go back and forth. So somekind of check if they already correct.
> > > > > > 
> > > > > > I have to skip correct pairs, that must be the solution.
> > > > > 
> > > > > Suggestions?
> > > > > 
> > > > > function untangle_links(arr)
> > > > > {
> > > > >    printnode = new Array;
> > > > >    var j = 0;
> > > > >    var tempnode = 0;
> > > > >    var tnode = new Array();
> > > > >    for(var i = 0; i < nodes; i ++ )
> > > > >    {
> > > > >       if(tempnode+1==arr[tempnode].nodelinks[j]) //SOMETHING......{i++}
> > > > >       for(var k = 0; k < tnode.length; k ++ )
> > > > >       {
> > > > >            if (arr[tempnode].nodelinks[j] == tnode[k])
> > > > >          {
> > > > >             j ++ ;
> > > > >          }
> > > > >       }
> > > > >       tempnode = arr[tempnode].nodelinks[j];
> > > > >       tnode[tnode.length] = tempnode;
> > > > >       printnode[i] = tempnode;
> > > > >       j = 0;
> > > > >    }
> > > > >    mytext+="Printnode[]"+printnode+"\n";
> > > > >    return printnode;
> > > > > }
> > > > 
> > > > ???
> > > > 
> > > > function untangle_links(arr)
> > > > {
> > > >    printnode = new Array;
> > > >    var j = 0;
> > > >    var tempnode = 0;
> > > >    var tnode = new Array();
> > > >    for(var i = 0; i < nodes; i ++ )
> > > >    {
> > > >       if(tempnode+1==arr[tempnode].nodelinks[j]) {i++;}
> > > >       else {
> > > >       for(var k = 0; k < tnode.length; k ++ )
> > > >       {
> > > >            if (arr[tempnode].nodelinks[j] == tnode[k])
> > > >          {
> > > >             j ++ ;
> > > >          }
> > > >       }
> > > >       tempnode = arr[tempnode].nodelinks[j];
> > > >       tnode[tnode.length] = tempnode;
> > > >       printnode[i] = tempnode;
> > > >       j = 0;
> > > >       }
> > > >    }
> > > >    mytext+="Printnode[]"+printnode+"\n";
> > > >    return printnode;
> > > > }
> > > 
> > > So anyone know the solution to this logic problem?
> > > I feel it quite close.
> > > 
> > > function untangle_links(arr)
> > > {
> > >    printnode = new Array;
> > >    var j = 0;
> > >    var tempnode = 0;
> > >    var tnode = new Array();
> > >    for(var i = 0; i < nodes; i ++ )
> > >    {
> > >       if(tempnode==i+1) {tnode[tnode.length]=i;i++;tempnode=i;}
> > >       else {
> > >       for(var k = 0; k < tnode.length; k ++ )
> > >       {
> > >            if (arr[tempnode].nodelinks[j] == tnode[k])
> > >          {
> > >             j ++ ;
> > >          }
> > >       }
> > >       tempnode = arr[tempnode].nodelinks[j];
> > >       tnode[tnode.length] = tempnode;
> > >       printnode[i] = tempnode;
> > >       j = 0;
> > >       }
> > >    }
> > >    mytext+="Printnode[]"+printnode+"\n";
> > >    return printnode;
> > > }
> > 
> > It is hairy...
> 
> If the link of the current node "sorted in place" to index i "whatever that may be", and that linked node is equal to node i+1?
> Then that next node is in correct place, so we skip it?
> 
> Hairy hairy

Well if i can sort the nodes and their interrelated links by hand i surely must be able to program the computer to do it. And i do not even try to sort them, i just try to find next node using the links of current node, but i must store the nodes already used.

It can't be that difficult maybe i make the problem harder than it is?

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