#include #include #include #include #define N 6 using namespace std; class list { public: int num; int ves; list *next; list(int n1, int n2) { num = n1; ves = n2; next=NULL; } }; class matr { public: list *ykaz[N]; int oc_ver[N]; bool bil[N]; matr() { for (int i=0; inext; delete del; } } } void poisk(int nnn) { int i; cout<<"переферия: "<nnn) { cout<<" "<ves<666 && (i_ver!=temp->num)) { oc_ver[temp->num]=min(temp->ves+oc_ver[i_ver],oc_ver[temp->num]); } temp=temp->next; } bil[i_ver]=true; //поиск новой вершины min_ves_ver=i_ver=666; for(i=0; ioc_ver[i]) { min_ves_ver=oc_ver[i]; i_ver=i; } } } } bool scet_is_faila() // считываем в матрицу { list *temp; FILE *f; char name[20]; int n; cout<<"\n введите имя файла: "; scanf("%s",name); if((f=fopen(name,"rb"))== NULL) { cout<<"\n ошибка открытия файла \n"; system("PAUSE"); return 1; } // чтение матрицы весов из файла cout<<"матрица весов данного графа:"<next) { temp=temp->next; } temp->next=new list(j,n); } } cout<"; temp=mat.ykaz[i]; while(temp) { cout << "(#"<< temp->num+1 << " вес=" << temp->ves << ") -> "; temp=temp->next; } cout<<"end"<>i_ver; mat.Dijkstra(i_ver); for (int i=0; i>nnn; mat.poisk(nnn); cout << endl; return 0; }