91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-07
  • 語言: C/C++
  • 標簽: 路徑??

資源簡介

從文件讀入。程序運行時輸入源點和目的節(jié)點,運行輸出在這兩點之間的所有路徑,并寫到輸出文件中,非常高效。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?

using?namespace?std;

int?INFINITY?=?0xffffffff;

int?main()
{
//????ifstream?in(“Graph10-20.txt“);
????ifstream?in(“graphExtention.txt“);
????//ifstream?in(“Graph7-12(1).txt“);
????ofstream?out(“paths.txt“);

????if(!in)
????{
????????cout?<????????return?1;
????}

????int?n?m?num;
????int?i?j;
int?pathCount?=?0;

????in?>>?n;

????int?size?=?n?;

????int?**graph?=?new?int*[size];
????for(i?=?0;?i?????{
????????graph[i]?=?new?int[size];
????????//?for(j?=?0;?j?????}

????for(i?=?0;?i?????????for(j?=?0;?j?????????????in?>>?graph[i][j];


????cout?<
????cout?<????int?from?to;
????cin?>>?from?>>?to;

????assert(from?????assert(to?
????vector?vqueue;
????vector?parent;
????int?pos?=?0;
????int?cur;


????int?top;
????int?count;

????stack?path;
????bool?visited?=?false;

????vector?whichOne;
????vector?nodeCount;
????for(i?=?0;?i?
????vqueue.push_back(from);
????parent.push_back(-1);
whichOne.push_back(1);
//nodeCount[from]++;

bool?changed?=?false;
????while(pos?????{
????????top?=?vqueue[pos++];
????????//?push?every?node?adjecent?to?the?queue
????????for(i?=?0;?i?????????{
????????????if(i?==?from)?continue;
????????????if(graph[top][i]?!=?0)
????????????{
????????????????//visited?before?
????????????????{
????????????????????visited?=?false;
????????????????????cur?=?pos?-?1;
????????????????????while(parent[cur]?!=?-1?&&?!visited)
????????????????????{
????

評論

共有 條評論