From 483d63fa7249ad8d6020680c48c3cf6df35010b3 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 26 Apr 2017 16:37:39 +0200 Subject: Moved all C++ files into CPP folder --- cpp/es4.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 cpp/es4.cpp (limited to 'cpp/es4.cpp') diff --git a/cpp/es4.cpp b/cpp/es4.cpp new file mode 100644 index 0000000..a1f1716 --- /dev/null +++ b/cpp/es4.cpp @@ -0,0 +1,67 @@ +#include +#define BIANCO 0 //Non Visitato +#define NERO 2 //Visitato +#define GRIGIO 1 //Non Finito +#define INF 999999 +#include +#include +#include +#define MAXN 9999 +#define INDEF -1 +#include +using namespace std; +typedef pair p; +int V,E; + +struct nodo { + vector

adj; + int dist; + nodo(){ + dist=INF; + } +}no[MAXN]; + int colore[MAXN]; + void relax (nodo no[], int u, int z) + { + p v= no[u].adj[z]; + if (no[v.first].dist> no[u].dist + v.second ) + { + no[v.first].dist= no[u].dist + v.second; + } + } + + void bf (nodo no[],int n, int s) + { + int i,j,z; + no[0].dist=0; + for (i=0;i>V>>E; + int a,b,c; + for (int i=0;i>a>>b>>c; + no[a].adj.push_back(p(b,c)); + } + bf(no,V,0); //Adiacenze, numeri di vertici, sorgente + for (int i=0;i