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

  • 大小: 99KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-09
  • 語言: 其他
  • 標簽:

資源簡介

鏈路狀態路由算法,求最大路徑,可以增刪路由。含報告。。。

資源截圖

代碼片段和文件信息

#include?
#include?
#define??routeTable?“routeTable.txt“

using?namespace?std;
const?int?AGE?=?10;???//節點生存跳數?
const?int?MAX_NODES?=?1024;??
const?int?INFINITY?=?100000;


int?dist[MAX_NODES][MAX_NODES];???//用于存放網絡拓撲結構連接矩陣?
int?static?Vnums;??//總的節點數?

void?initDist(){????//初始化鄰接矩陣?
?for(int?i?=?0;?i? ?????for(int?j?=?0;?j? ????????dist[i][j]?=?0;
?}?

void?creatRouteMap(int?Vnums){????//創建網絡拓撲結構的鄰接矩陣?
?for(int?i?=?0;?i? ???{?
????????????cout?< ?? for(int?j?=?0;?j? ?? ???{
??? ???cout?< ??? ???cin?>>?dist[i][j];
???????????}
??????}
?}?

void?saveRoute(ofstream&?routeTables){??//保存路由信息?
?????routeTables?<?????routeTables?<?????routeTables?<?????routeTables?< ?for(int?i?=?0;?i? ???{?
?? ?for(int?j?=?0;?j? ?? ???{
??? ???
??? ???routeTables< ???????????}
????????routeTables?<???????}
?????
?????}
?????
void?dijkstra(int?s?int?t?int?path[]){
?struct?state{?????????//存放節點數據?
???int?predecessor;???//父節點?
???int?length;????????//權值?
???bool??lable;??//訪問狀態?
???}state[MAX_NODES];
?????
?????int?ijkmin;?
?struct?state?*p;
?for(p?=?&state[0];?p? ????{
??? ?p->predecessor?=?-1;
??? ?p->length?=?INFINITY;
??? ?p->lable?=?false;
}
state[t].length?=?0;
state[t].lable?=?true;
k?=?t;

do{
??? for(int?i?=?0;?i????????????if(?(dist[k][i]?!=?0)?&&?(state[i].lable?==?false))
??????????????if(state[k].length?+?dist[k][i]??????????????????{
?? ??state[i].predecessor?=?k;??//記錄節點?
?? ??cout?<“;?
??????????????state[i].length?=?state[k].length?+?dist[k][i];??//路徑長度總和
?????????}
k?=?0;
????min?=?INFINITY;
??? for(int?i?=?0;?i? ????if((state[i].lable?==?false)?&&?(state[i].length? ???{
??? ???min?=?state[i].length; ??
???????????????????k?=?i; ?
????????????????}???
state[k].lable?=?true;?
???}while(k!=s);
??????cout?< ?}

void?addRoute(){??//添加一個路由及結點信息?
?????char?ch;
?????do{
?????cout?<?????Vnums?=?Vnums?+?1;
?????cout?< ?? for(int?j?=?0;?j? ?? ???{
??? ???cout?< ??? ???cin?>>?dist[Vnums?-?1][j];???//對應行的信息?
??? ???dist[j][Vnums?-?1]?=?dist[Vnums?-?1][j];?//對應列的信息?
???????????}
?????cout?<?????cin?>>?ch;
?????if(ch?==?‘n‘)?break;
???????}while(ch?==?‘y‘);
?????}

void?deleteRoute(){
?char?ch;
?int?delNum;?
?????do{
?????cout?<?????cin?>>?delNum;?
?????for(int?j?=?0;?j? ?? ???{
??? ???dist[delNum?-?1][j]?=?0;???//對應行的信息?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????207360??2010-12-23?21:42??鏈路狀態路由算法實驗.doc

?????文件???????6122??2010-12-18?20:11??鏈路狀態路由算法.cpp

-----------?---------??----------?-----??----

???????????????213482????????????????????2


評論

共有 條評論