I have this code:
const int maxnodes = 5000;
struct Edge
{
int to, rev;
int f, cap;
};
vector g[maxnodes];
This is qui
1) int nodes = maxnodes, src, dest;
Here, nodes is an int initialized with the value same as that of maxnodes. src and dest are also int, but with no initial value.
2) vector
g is here an array of std::vector.
Edge &e = g[u][j];
Q. What is g[u][j]?
A. It is the Edge stored in g at the uth row and jth column.
Q. g is vector filled with Edge struct, how can it be act like a array of arrays?
A. Because std::vector has operator[] overloaded for itself in its definition. Refer: http://en.cppreference.com/w/cpp/container/vector/operator_at