⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awdbfs.cpp

📁 data structures, algorithms and Application书的源代码
💻 CPP
字号:
// test breadth first search on adjacency matrix weighted digraphs

#include <iostream.h>
#include <stdlib.h>
#include <math.h>
#include "awd.h"

void main(void)
{
   AdjacencyWDigraph<int> G(7);
   int reach[8];
   int n = 7;
   cout << "enter number of edges" << endl;
   int e, u, v, w;
   cin >> e;
   for (int i =1; i <= e; i++) {
    cout << "enter edge " << i << endl;
    cin >> u >> v >> w;
    G.Add(u,v,w);}
   for (int i=1; i<=n; i++)
       reach[i] = 0;
   G.BFS(1, reach, 1);
   G.BFS(4, reach, 2);
   G.BFS(7, reach, 3);
   for (int i=1; i<=n; i++)
      cout << reach[i] << ' ';
   cout << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -