Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #define INF (1 << 29)
- using namespace std;
- struct Arista
- {
- int hacia, costo;
- };
- Arista armarArista(int hacia, int costo)
- {
- Arista ar;
- ar.hacia = hacia;
- ar.costo = costo;
- return ar;
- }
- struct Grafo
- {
- vector <vector <Arista> > adj;
- vector <vector <int> > m;
- int nodos, aristas;
- void leer()
- {
- cin >> nodos >> aristas;
- adj.resize(nodos+1);
- m = vector <vector <int> > (nodos+1, vector <int> (nodos+1, INF));
- int desde, hacia, costo;
- for(int i=0; i<aristas; i++)
- {
- cin >> desde >> hacia >> costo;
- adj[desde].push_back(armarArista(hacia, costo));
- adj[hacia].push_back(armarArista(desde, costo));
- m[desde][hacia] = costo;
- m[hacia][desde] = costo;
- }
- }
- void floydWarshall() ///MAGIA
- {
- for(int k=1; k<=nodos; k++)
- for(int i=1; i<=nodos; i++)
- for(int j=1; j<=nodos; j++)
- m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
- }
- };
- int main()
- {
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment