//#include<iostream>
//#include<vector>
//#include<stack>
//using namespace std;
//
//#define INF 100001
//#define maxv 100
//vector<int> st;
//
//stack<int> stk;
//int eTop = 0;
//int src[maxv][maxv]; //用于存储结点到结点之间的最短路径距离
//int path[maxv][maxv]; //用于存储所经过的节点
//
////边的结构体
//struct Edge
//{
// int u, v, len; //起点,终点,权
// Edge* next; //下一条边
//}epool[maxv];
//
////点的结构体
//struct Node
//{
// Edge* first; //第一条边
//};
//
////图的结构体
//struct Graph
//{
// int e, n; //边数与顶点数
// Node adj[maxv];
//};
//
////测试的数据
//class Data
//{
//public:
// Data(int u, int v, int len)
// {
// this->m_u = u;
// this->m_v = v;
// this->m_len = len;
// }
// int m_u;
// int m_v;
// int m_len;
//};
//
//void insertData(vector<Data>& vd)
//{
// Data d1(1, 2, 4);
// Data d2(1, 3, 6);
// Data d3(1, 4, 6);
// Data d4(2, 3, 1);
// Data d5(2, 5, 7);
// Data d6(3, 5, 6);
// Data d7(3, 6, 4);
// Data d8(4, 3, 2);
// Data d9(4, 6, 5);
// Data d10(5, 7, 6);
// Data d11(6, 5, 1);
// Data d12(6, 7, 8);
// vd.push_back(d1);
// vd.push_back(d2);
// vd.push_back(d3);
// vd.push_back(d4);
// vd.push_back(d5);
// vd.push_back(d6);
// vd.push_back(d7);
// vd.push_back(d8);
// vd.push_back(d9);
// vd.push_back(d10);
// vd.push_back(d11);
// vd.push_back(d12);
//}
//
//void initArray(Graph& g, int src[maxv][maxv], int path[maxv][maxv])
//{
// for (int i = 1; i <= g.n; i++)
// {
// for (int j = 1; j <= g.n; j++)
// {
// if (i == j)
// {
// src[i][j] = 0;
// }
// else
// {
// src[i][j] = INF;
// }
// }
// }
// for (int i = 1; i <= g.n; i++)
// {
// while (g.adj[i].first)
// {
// src[i][g.adj[i].first->v] = g.adj[i].first->len;
// g.adj[i].first = g.adj[i].first->next;
// }
// }
// for (int i = 1; i <= g.n; i++)
// {
// for (int j = 1; j <= g.n; j++)
// {
// if (i != j && src[i][j] < INF) //i到j有边时
// {
// path[i][j] = i;
// }
// else
// {
// path[i][j] = -1; //i到j有边时
// }
// }
// }
//}
//
//void printArray(Graph& g, int array[maxv][maxv])
//{
// for (int i = 1; i <= g.n; i++)
// {
// for (int j = 1; j <= g.n; j++)
// {
// cout << "\t" << array[i][j] << " ";
// }
// cout << endl;
// }
//}
//
//bool dfs(Graph& g, int u)
//{
// st[u] = 1; //正在dfs
// while (g.adj[u].first)
// {
// int v = g.adj[u].first->v;
// if (st[v] == 1)
// {
// return true;
// }
// if (st[v] == 0 && dfs(g, v))
// {
// return true;
// }
// g.adj[u].first = g.adj[u].first->next;
// }
// st[u] = -1; //结束
// stk.push(u);
// return false;
//}
//
//void addEdge(Graph& g, int u, int v, int len)
//{
// epool[eTop].u = u;
// epool[eTop].v = v;
// epool[eTop].len = len;
// epool[eTop].next = g.adj[u].first;
// g.adj[u].first = &epool[eTop];
// eTop++;
//}
//
//void creatGraph(Graph& g)
//{
// vector<Data> vd;
// insertData(vd);
// g.n = 7;
// st.assign(g.n + 1, 0); //将st数组内的值初始化为0
// for (int i = 1; i <= g.n; i++)
// {
// g.adj[i].first = NULL; //将每个顶点的初始值置为空
// }
// g.e = vd.size();
// for (auto it = vd.begin(); it != vd.end(); it++)
// {
// addEdge(g, (*it).m_u, (*it).m_v, (*it).m_len);
// }
// Graph g1 = g;
// for (int i = 1; i <= g.n; i++)
// {
// if (!st[i] && dfs(g1, i))
// {
// cout << "图中有环!" << endl;
// }
// }
//}
//void displayPath(Graph& g, int src[maxv][maxv], int path[maxv][maxv])
//{
// stack<int> aPath;
// for (int i = 1; i <= g.n; i++)
// {
// for (int j = 1; j <= g.n; j++)
// {
// if (i != j && src[i][j] < INF) //存在路径
// {
// cout << "从" << i << "到" << j << "的路径为:" << " ";
// aPath.push(j);
// int k = path[i][j];
// while (k != -1 && k != i)
// {
// aPath.push(k);
// k = path[i][k];
// }
// if (k == i)
// {
// aPath.push(i);
// }
// //打印路径
// while (!aPath.empty())
// {
// if (aPath.size() == 1)
// {
// cout << aPath.top() <<" ";
// aPath.pop();
// }
// else
// {
// cout << aPath.top() << "->";
// aPath.pop();
// }
// }
// cout << "最短路径长度为:" << src[i][j] << endl;
// }
// }
// }
//}
//
//void flody(Graph& g, int src[maxv][maxv], int path[maxv][maxv])
//{
// for (int k = 1; k <= g.n; k++)
// {
// for (int i = 1; i <= g.n; i++)
// {
// for (int j = 1; j <= g.n; j++)
// {
// if (src[i][j] > src[i][k] + src[k][j])
// {
// src[i][j] = src[i][k] + src[k][j];
// path[i][j] = path[k][j];
// }
// }
// }
// }
//}
//
//int main()
//{
// Graph g;
// creatGraph(g);
// while (!stk.empty())
// {
// cout << stk.top() << " ";
// stk.pop();
// }
// cout << endl;
// initArray(g, src, path);
// cout << "---------Flody前----------" << endl;
// printArray(g, src);
// cout << "--------------------------" << endl;
// printArray(g, path);
// flody(g, src, path);
// cout << "---------Flody后----------" << endl;
// printArray(g, src);
// cout << "--------------------------" << endl;
// printArray(g, path);
// cout << "--------------------------" << endl;
// displayPath(g, src, path);
// system("pause");
// return 0;
//}
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
弗洛伊德算法.7z (24个子文件)
弗洛伊德算法
弗洛伊德算法.sdf 8.06MB
弗洛伊德算法.sln 1000B
弗洛伊德算法.v12.suo 30KB
弗洛伊德算法
FloydSort.cpp 5KB
Floyd.cpp 5KB
弗洛伊德算法.vcxproj 3KB
FloydMy.cpp 4KB
Debug
vc120.pdb 484KB
FloydMy.obj 333KB
弗洛伊德算法.tlog
CL.write.1.tlog 2KB
CL.read.1.tlog 22KB
cl.command.1.tlog 2KB
link.write.1.tlog 516B
link.command.1.tlog 2KB
link.read.1.tlog 3KB
弗洛伊德算法.lastbuildstate 166B
弗洛伊德算法.log 1KB
FloydSort.obj 2KB
Floyd.obj 2KB
vc120.idb 363KB
弗洛伊德算法.vcxproj.filters 1KB
Debug
弗洛伊德算法.ilk 590KB
弗洛伊德算法.pdb 1.53MB
弗洛伊德算法.exe 102KB
共 24 条
- 1
qq_35019155
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0