0

I have a graph with 5811 vertices; only known at run-time and thus could be anything but usually less than 6000. Initializing the vertices takes up a lot of time at 35 milliseconds. I was wondering if anyone has a suggestion on how I can improve the vertex allocation speed ? I have looked through some other threads but it seems like there is no definite solution.

EDIT: It takes 35ms due to the amount of variables present in each vertex

//find amount of vertices required
//...   

//35ms
//initialize vertices
for (int i = 0; i < max + 1; i++)   boost::add_vertex(i, g);

//10ms
//fill up adjacency list and accumulate vertex information
for (int row = 0; row < label.rows; row++)  
    for (int col = 0; col < label.cols; col++)
    {
         //process data
    }
Kong
  • 2,202
  • 8
  • 28
  • 56
  • We can't see anything at all here. You never show /any/ of the relevant types. You don't tell us where the data come from etc. I'm very very happy to help you optimize code, but invisible code doesn't exist. Voting to close. – sehe Mar 24 '17 at 19:12
  • You can take a look at this [trick](http://stackoverflow.com/a/19358213/2876861) to accelerate the vertex allocations – Michael Simbirsky Apr 04 '17 at 21:39

0 Answers0