/*********************************************************** * @Description : 读取图的测试 * @author : 梁山广(Laing Shan Guang) * @date : 2018/4/30 13:31 * @email : liangshanguang2@gmail.com ***********************************************************/ #include #include #include #include #include #include "SparseGraph.h" #include "DenseGraph.h" #include "ReadGraph.h" #include "LazyPrimMST.h" #include "PrimMST.h" using namespace std; int main(void) { clock_t startTime, endTime; string fileName = "testG4.txt"; int vertices = 10000; // G1:8条边; G2:250 G3:1000 G4:10000 . 切换不同的测试文件记得这里也要改哈 cout << fixed << setprecision(2); // 保留2位小数 cout << "*************************************加权稀疏图************************************" << endl; // 1. Lazy的Prim算法 // false代表为无向图 SparseGraph sparseGraph = SparseGraph(vertices, false); ReadGraph, double> readSparseGraph(sparseGraph, fileName); cout << "Test Lazy Prim MST: " << endl; startTime = clock(); LazyPrimMST, double> lazyPrimMST(sparseGraph); endTime = clock(); cout<<"cost time: "<<(double)(endTime-startTime)/CLOCKS_PER_SEC<<" s."<, double> primMST(sparseGraph); endTime = clock(); cout<<"cost time: "<<(double)(endTime-startTime)/CLOCKS_PER_SEC<<" s."<