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


Groups > comp.lang.javascript > #29866 > unrolled thread

Untangle node positions "logic problem"

Started byjonas.thornvall@gmail.com
First post2016-03-09 11:15 -0800
Last post2016-03-13 17:22 +0100
Articles 20 on this page of 21 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

Page 1 of 2  [1] 2  Next page →


#29866 — Untangle node positions "logic problem"

Fromjonas.thornvall@gmail.com
Date2016-03-09 11:15 -0800
SubjectUntangle node positions "logic problem"
Message-ID<9c01e4ae-f564-4d42-91cb-3c0c858edd7a@googlegroups.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;
  }
}

[toc] | [next] | [standalone]


#29867

Fromjonas.thornvall@gmail.com
Date2016-03-09 11:59 -0800
Message-ID<33306987-a34c-4c89-bfec-b53b021af527@googlegroups.com>
In reply to#29866
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.

[toc] | [prev] | [next] | [standalone]


#29868

Fromjonas.thornvall@gmail.com
Date2016-03-09 12:40 -0800
Message-ID<1b4bed87-c220-45dd-874e-df113093da65@googlegroups.com>
In reply to#29867
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;
  }
}

[toc] | [prev] | [next] | [standalone]


#29869

Fromjonas.thornvall@gmail.com
Date2016-03-09 12:54 -0800
Message-ID<0835c492-4d75-41b2-af21-a8ddb3332265@googlegroups.com>
In reply to#29868
Den onsdag 9 mars 2016 kl. 21:40:53 UTC+1 skrev jonas.t...@gmail.com:
> 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;
>   }
> }

A bit confusing tempnode ->tempnodes[] changed to tnode

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]=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;
  }
}

[toc] | [prev] | [next] | [standalone]


#29870

Fromjonas.thornvall@gmail.com
Date2016-03-09 12:57 -0800
Message-ID<cca37ef9-a13a-48f9-8725-08be4ef89d59@googlegroups.com>
In reply to#29869
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;
  }
}

[toc] | [prev] | [next] | [standalone]


#29871

Fromjonas.thornvall@gmail.com
Date2016-03-09 13:00 -0800
Message-ID<eaba4b53-dbfe-4675-a46c-ace1cd9f446c@googlegroups.com>
In reply to#29870
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.

[toc] | [prev] | [next] | [standalone]


#29873

Fromjonas.thornvall@gmail.com
Date2016-03-09 13:29 -0800
Message-ID<830e233b-832f-4cce-9849-29af873fc7e7@googlegroups.com>
In reply to#29871
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.

http://jt.node365.se/nodes16.html

[toc] | [prev] | [next] | [standalone]


#29874

Fromjonas.thornvall@gmail.com
Date2016-03-09 13:41 -0800
Message-ID<9b79dba4-b072-4b0f-a274-2227282e7006@googlegroups.com>
In reply to#29871
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+

[toc] | [prev] | [next] | [standalone]


#29875

Fromjonas.thornvall@gmail.com
Date2016-03-09 17:15 -0800
Message-ID<6909efce-ec60-4713-bba2-1a8d545f2c5a@googlegroups.com>
In reply to#29874
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+

Something wrong with approach have to start over, it swap back and forth.

[toc] | [prev] | [next] | [standalone]


#29876

Fromjonas.thornvall@gmail.com
Date2016-03-09 17:21 -0800
Message-ID<ab549247-b7f7-438f-9ae5-a3a83507c0b8@googlegroups.com>
In reply to#29874
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.

[toc] | [prev] | [next] | [standalone]


#29877

Fromjonas.thornvall@gmail.com
Date2016-03-09 22:52 -0800
Message-ID<b9bf1920-4805-4608-a063-8b2c5969777a@googlegroups.com>
In reply to#29876
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

[toc] | [prev] | [next] | [standalone]


#29879

Fromjonas.thornvall@gmail.com
Date2016-03-10 13:09 -0800
Message-ID<251aafbf-f180-4872-85cc-44e99a0f1b3e@googlegroups.com>
In reply to#29877
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;
}

[toc] | [prev] | [next] | [standalone]


#29889

Fromjonas.thornvall@gmail.com
Date2016-03-11 00:24 -0800
Message-ID<41e98b06-a0f8-4ac1-9265-92fd42fde502@googlegroups.com>
In reply to#29879
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.

[toc] | [prev] | [next] | [standalone]


#29890

Fromjonas.thornvall@gmail.com
Date2016-03-11 00:49 -0800
Message-ID<6580e47f-d201-4f11-9a0f-fee5b007a00b@googlegroups.com>
In reply to#29889
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;
}

[toc] | [prev] | [next] | [standalone]


#29891

Fromjonas.thornvall@gmail.com
Date2016-03-11 00:53 -0800
Message-ID<1a254e78-4e61-41bc-a2c1-bfe97b0aa05e@googlegroups.com>
In reply to#29890
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;
}

[toc] | [prev] | [next] | [standalone]


#29892

Fromjonas.thornvall@gmail.com
Date2016-03-11 01:21 -0800
Message-ID<bc9fc91e-9198-4056-9eae-9ed17f220919@googlegroups.com>
In reply to#29891
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;
}

[toc] | [prev] | [next] | [standalone]


#29893

Fromjonas.thornvall@gmail.com
Date2016-03-11 01:29 -0800
Message-ID<58197b65-023c-4bf3-8aa7-50e6d679b920@googlegroups.com>
In reply to#29892
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...

[toc] | [prev] | [next] | [standalone]


#29894

Fromjonas.thornvall@gmail.com
Date2016-03-11 01:41 -0800
Message-ID<4bb8b3ef-ab56-48d8-97f7-d7f16528db8d@googlegroups.com>
In reply to#29893
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

[toc] | [prev] | [next] | [standalone]


#29895

Fromjonas.thornvall@gmail.com
Date2016-03-11 01:58 -0800
Message-ID<aedc54e5-183e-44ef-bf2c-1b2b583bf66c@googlegroups.com>
In reply to#29894
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?

[toc] | [prev] | [next] | [standalone]


#29957

Fromjonas.thornvall@gmail.com
Date2016-03-13 04:19 -0700
Message-ID<268e7d4e-19b1-4d72-b61d-deb6730ed3c9@googlegroups.com>
In reply to#29895
Den fredag 11 mars 2016 kl. 10:59:09 UTC+1 skrev jonas.t...@gmail.com:
> 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?

I think i did it if anyone can find it go wrong in printorder shout.
http://jt.node365.se/mydebug4.html
Well i know it isn't easy to follow graph connections without visual aid.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web