lwgiter.cpp

来自「数据结构c++语言描述 Borland C++实现」· C++ 代码 · 共 45 行

CPP
45
字号

#include <iostream.h>
#include "lwdgph2.h"
#include "lwgiter.h"

void main(void)
{
   LinkedWDigraph<int> G(1);
   G.Input();
   cout << "The graph has " << G.Edges() << " edges." << endl;
   G.Output();

   // output adjacent vertices
   int n = G.Vertices();
   LinkedWeightedIterator<int> x;
   for (int i = 1; i <= n; i++) {
      cout << "The vertices adjacent to vertex "
           << i << " are" << endl;
      int v = x.Begin(G,i);
      while (v) {
         cout << v << "  ";
         v = x.NextVertex();
         }
      cout << endl;
      }

   cin >> G;
   cout << "The graph has " << G.Edges() << " edges." << endl;
   cout << G << endl;

   // output adjacent vertices
   n = G.Vertices();
   for (int i = 1; i <= n; i++) {
      cout << "The vertices adjacent to vertex "
           << i << " are" << endl;
      int v = x.Begin(G,i);
      while (v) {
         cout << v << "  ";
         v = x.NextVertex();
         }
      cout << endl;
      }

}

⌨️ 快捷键说明

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