Best Way To represent Graph Using C++ While Solving Problems

Hi Codechefers,

I am trying to solve some problems based on Graph using C++ I am very beginner in Graph theory and solving graph related problems.
I have come across many representation of graph

1 . Declaring vector<int>adj[100001] : global declaration with Predefined size
2 . locally declaring vector<int > adj[n] : here n is as per input size in test case

Could some one please explain which one is better approach. I am bit confused in this.

It basically never matters. All that’s important is that the size is big enough to store everything.

1 Like

@galencolin Thanks for suggesting.