guys i wanna ask about this code
int main() {
int t, N, m, s, T;
int u, v, w, i;
scanf( "%d", &t );
while ( t > 0 ) {
scanf( "%d%d%d%d", &N, &m, &s, &T );
vector< edge > graph[ N + 1 ];
for ( i = 0; i < m; ++i ) {
scanf( "%d%d%d", &u, &v, &w );
graph[ u ].push_back( ( edge ) { v, w } );
graph[ v ].push_back( ( edge ) { u, w } );
}
dijkstra( graph, N, s, T );
--t;
}
return 0;
}
whats graph[ u ].push_back( ( edge ) { v, w } ); function ??
graph is an array of vector<edge>
So graph[i] is i'th vector in this array. graph[i].push_back(/*...*/); adds another edge to this array ( edge ) { u, w } constructs an edge from integers u and w
So graph[ u ].push_back( ( edge ) { v, w } ); adds new edge {u, w} to the u'th vector int the graph array.