博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2016年3月2日

摘要: ///通过队列,找出最小的dis[]值,取出配对的vertex值。 /// stack priority_queue set struct edge { int to; int cost; } ; vector <edge>G[MZX_V];///表 typedef pair<int ,int > 阅读全文

posted @ 2016-03-02 22:27 shaoweiyi 阅读(179) 评论(0) 推荐(0) 编辑

摘要: ///标准的dijkstra算法 void dijkstra() { while(true) { int vert=-1; dis[-1]=INF; for(int i=0;i<num_v;i++) { if( (!used[i]) && ( vert==-1||dis[i]<dis[vert] ) 阅读全文

posted @ 2016-03-02 21:22 shaoweiyi 阅读(235) 评论(0) 推荐(0) 编辑

摘要: ///单源最短路问题 ///DAG:单向不循环图 ///问题的特殊性:要对变进行遍历,而不是顶点 const int MAX_V=; const int MAX_E=; const int INF=; int num_v; int num_e; int start; int aim; struct 阅读全文

posted @ 2016-03-02 20:04 shaoweiyi 阅读(119) 评论(0) 推荐(0) 编辑

摘要: ///图的搜索:两色染色问题 vector<int>G[MAX_V]; color[MAX_V]; bool dfs (int i,int c) { color[i]=c; for(int j=0;i<G[i].size();j++) { if(color[ G[i][j] ]==c) return 阅读全文

posted @ 2016-03-02 18:55 shaoweiyi 阅读(162) 评论(0) 推荐(0) 编辑

摘要: struct vertex { // edge: vector <vertex*> edge; /*vertex的其他属性*/ }; vertex G[max_v]; int main() { int num_e; int num_v; cin>>num_v>>num_e; for(int i=0; 阅读全文

posted @ 2016-03-02 17:44 shaoweiyi 阅读(115) 评论(0) 推荐(0) 编辑

摘要: const int MAX_E=; const int MAX_V=; vector <int> G[MAX_V]; /* 有其他属性的是 struct edge {int to; int cost;}; vector<edge>G[MAX_V]; */ int main() { int num_e 阅读全文

posted @ 2016-03-02 13:37 shaoweiyi 阅读(150) 评论(0) 推荐(0) 编辑