P
pereges
Hi, I'm in a bit of dilemma here.
I want to use an adjacency matrix for building edge lists in my
project.
The thing is an adjacency matrix will have nv * nv elements where nv
is number of vertices. Advantage is that it makes things very fast in
my project, only one pass over list of triangles as opposed to two.
But I'm a little skeptical about allocating memory for nv * nv
elements. nv can be very high up to 10,000,000 as well. Storing
10,000,000 * 10,000,000 elements might actually be an extremely
stupid idea which may not even be allowed. Also, while creating the
matrix also a lot of time may be spent :
typedef int **m;
matrix create_matrix(size_t cols, size_t rows)
{
size_t i;
matrix m;
m = (int **) malloc(rows * sizeof(int *));
for (i = 0; i < rows; i++)
{
m = (int *) malloc(cols * sizeof(int));
}
return (m);
}
You still have to make nv passes here.
And then I want to do some initializations using memset i.e. all
values must be zero initially. I don't know the internal workings of
memset so once again I'm fearing that it will slow my program even
more. Is there an easier way out of this ?
I want to use an adjacency matrix for building edge lists in my
project.
The thing is an adjacency matrix will have nv * nv elements where nv
is number of vertices. Advantage is that it makes things very fast in
my project, only one pass over list of triangles as opposed to two.
But I'm a little skeptical about allocating memory for nv * nv
elements. nv can be very high up to 10,000,000 as well. Storing
10,000,000 * 10,000,000 elements might actually be an extremely
stupid idea which may not even be allowed. Also, while creating the
matrix also a lot of time may be spent :
typedef int **m;
matrix create_matrix(size_t cols, size_t rows)
{
size_t i;
matrix m;
m = (int **) malloc(rows * sizeof(int *));
for (i = 0; i < rows; i++)
{
m = (int *) malloc(cols * sizeof(int));
}
return (m);
}
You still have to make nv passes here.
And then I want to do some initializations using memset i.e. all
values must be zero initially. I don't know the internal workings of
memset so once again I'm fearing that it will slow my program even
more. Is there an easier way out of this ?