Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32716
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2017-03-10 17:22 -0800 |
| References | <0b2b904e-4692-41df-9afa-09e75baf6564@googlegroups.com> <4v2lk5osyqci.96v522es0gyo$.dlg@40tude.net> <c4cec846-0e38-497a-87ca-3c8230eeca61@googlegroups.com> |
| Message-ID | <331d8d6c-64ca-4e78-816e-e234788122e9@googlegroups.com> (permalink) |
| Subject | Re: Remove links |
| From | jonas.thornvall@gmail.com |
Den måndag 6 mars 2017 kl. 14:52:46 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 6 mars 2017 kl. 12:12:19 UTC+1 skrev JJ:
> > On Sun, 5 Mar 2017 15:00:47 -0800 (PST), jonas.thornvall@gmail.com wrote:
> > > My function to create links from a list of marke nodes work fine, so i
> > > thought rather than reinvent the wheel i use the same function to remove
> > > links, replacing push with splice i have not debugged yet because i can't
> > > see why the approach should not work. If someone understand the problem
> > > just by a look, i would be greatful if you explain it.
> > >
> > > function createMarkedLinks() {//Works
> > [snip]
> >
> > Can't be tested without knowing the initial array contents of `marklist` and
> > `arr`.
>
> http://anybase.co.nf
>
> Well arr[].nodelinks[] are just integers
> And so are markedlist[] it is a list of *MARKED* arr[] integer elements
>
> Say marklist hold 1,2,3 then createMarkedLinks connect them by set nodelinks for each node. See script Graphdata.
>
> And of course to remove links there must already be links, so if 1,2,3 marked to be removed the doublechained connections/links below should be spliced.
> arrlinks[1].nodelinks[2], arrlinks[1].nodelinks[3]
> arrlinks[2].nodelinks[1],arrlinks[2].nodelinks[3]
> arrlinks[3].nodelinks[1],arrlinks[3].nodelinks[2]
Well the linkremoval i will fix tomorrow, but i did fix node removal with reordering and that was a bit hairy to think out. It probably would been easier remove all the nodes and make the reorder afterwards. But thinking a bit deeper i managed to see into the future.It is a pretty hard thing making a list that is changed as you remove items and still get it right.
http://anybase.co.nf
function RMN() {
if (z > -1) {
var tr = arr[z].nodelinks.length;
for (s = 0; s < tr; s++) {
remove = arr[z].nodelinks[s];
var index = arr[remove].nodelinks.indexOf(z);
arr[remove].nodelinks.splice(index, 1);
}
arr[z].nodelinks = [];
}
if (zeromark == true) {
marklist.pop();
} else {
marklist.splice(0, 1);
}
reOrderArr(z);
autotext = "Marked=" + marklist + "\n";
update_GraphData();
}
function removeMarkedNodes() {
iterate = marklist.length;
for (var x = 0; x < iterate; x++) {
z = marklist[0];
if (arr[arr.length - 1].bcolor == "red") {
zeromark = true;
} else {
zeromark = false;
}
// alert(z);
RMN(z);
update_Marklist();
}
}
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Remove links jonas.thornvall@gmail.com - 2017-03-05 15:00 -0800
Re: Remove links jonas.thornvall@gmail.com - 2017-03-06 02:26 -0800
Re: Remove links JJ <jj4public@vfemail.net> - 2017-03-06 18:12 +0700
Re: Remove links jonas.thornvall@gmail.com - 2017-03-06 05:52 -0800
Re: Remove links jonas.thornvall@gmail.com - 2017-03-10 17:22 -0800
Re: Remove links jonas.thornvall@gmail.com - 2017-03-15 01:21 -0700
Re: Remove links jonas.thornvall@gmail.com - 2017-03-15 01:52 -0700
Re: Remove links jonas.thornvall@gmail.com - 2017-03-15 05:11 -0700
Re: Remove links jonas.thornvall@gmail.com - 2017-03-16 01:26 -0700
Re: Remove links jonas.thornvall@gmail.com - 2017-03-16 03:39 -0700
csiph-web