I'm running some analysis that requires the creation, row by row, of a large list of lists. The big list is called "Nodes" and it will ultimately contain hundreds of thousands of rows. The first few rows will look like this ...
Row 1: {{1,3,5}, {2,4,6}, {7}, {6,7,8,9}}
Row 2: {{7,3,8}, {2,5,4}, {2}, {6,2,8,4}}
Row 3: {{9,7,5}, {5,4,6}, {1}, {6,7,8,9}}
I've tried AppendTo and Join in this way ...
Nodes = AppendTo[Nodes,List[{8,3,2},{1,2,3},{8},{8,3,3,2}]];
Nodes = Join[Nodes,List[{8,3,2},{1,2,3},{8},{8,3,3,2}]];
and they both take quite a long time to run.
I also tried creating a huge Nodes array ahead of time and then replacing each row, something like this ...
Nodes = Range[200000];
For[ji = 1, ji < 200001, ji++, Nodes[[ji]] = List[{}, {}, {}, {}]];
followed by
Nodes[[nodesrownumber]] = List[{8,3,2},{1,2,3},{8},{8,3,3,2}]];
and this seems to take even longer.
Any suggestions for improving the speed of this? Thanks, very much, in advance.
Comments
Post a Comment