上一页 1 2 3 4 5 6 ··· 38 下一页
摘要: 前提不能有负权边,同样借助最小索引堆实现 #include <iostream> #include <vector> #include <stack> #include "Edge.h" #include "IndexMinHeap.h" using namespace std; template< 阅读全文
posted @ 2020-04-11 09:50 Erick-LONG 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 先排序,挑最小权值,并利用并查集判断不能形成环 #include <iostream> #include <vector> #include "MinHeap.h" #include "UnionFind5.h" #include "Edge.h" using namespace std; temp 阅读全文
posted @ 2020-04-09 13:37 Erick-LONG 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 利用最小索引堆优化prim #include <iostream> #include <vector> #include <cassert> #include "Edge.h" #include "IndexMinHeap.h" using namespace std; template<typen 阅读全文
posted @ 2020-04-09 13:13 Erick-LONG 阅读(185) 评论(0) 推荐(0) 编辑
摘要: #include "MinHeap.h" using namespace std; template<typename Graph,typename Weight> class LazyPrimMST { private: Graph &G; MinHeap<Edge<Weight>> pq;//最 阅读全文
posted @ 2020-04-06 11:37 Erick-LONG 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 稠密图 #ifndef DENSEGRAPH_H #define DENSEGRAPH_H #include <iostream> #include <vector> #include <cassert> #include "Edge.h" using namespace std; //稠密图 -- 阅读全文
posted @ 2020-04-06 10:57 Erick-LONG 阅读(309) 评论(0) 推荐(0) 编辑
摘要: #include <cassert> #include <vector> template<typename Graph> class ShortestPath { private: Graph &G; int s; //某一个点 bool* visited; int* from;//路径 int 阅读全文
posted @ 2020-04-02 22:05 Erick-LONG 阅读(370) 评论(0) 推荐(0) 编辑
摘要: #include <cassert> #include <vector> template<typename Graph> class Path { private: Graph &G; int s; //某一个点 bool* visited; int* from;//路径 void dfs(int 阅读全文
posted @ 2020-04-02 21:48 Erick-LONG 阅读(414) 评论(0) 推荐(0) 编辑
摘要: #ifndef COMPONENT_H #define COMPONENT_H #include <iostream> #include <cassert> using namespace std; //图的深度优先遍历 template<typename Graph> class Componen 阅读全文
posted @ 2020-04-02 21:27 Erick-LONG 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 稀疏图 #ifndef SPARSEGRAPH_H #define SPARSEGRAPH_H #include <iostream> #include <vector> #include <cassert> using namespace std; //稀疏图图 -- 邻接表 class Spar 阅读全文
posted @ 2020-04-02 13:09 Erick-LONG 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 查询两个节点是否连接,把两个节点相连,并查集 #ifndef UNIONFIND_UNIONFIND5_H #define UNIONFIND_UNIONFIN5_H #include <iostream> #include <cassert> using namespace std; namesp 阅读全文
posted @ 2020-04-01 22:36 Erick-LONG 阅读(175) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 38 下一页