lwgraph.cpp

来自「常用算法与数据结构原代码」· C++ 代码 · 共 33 行

CPP
33
字号
// test of linked adjacency list weighted graph class

#include <iostream.h>
#include "lwgraph.h"

void main(void)
{
   LinkedWDigraph<int> L(4);
	cout << "Edges = " << L.Edges() << endl;
	L.Add(2,4,1).Add(1,3,2).Add(2,1,3).Add(1,4,4).Add(4,2,5);
	cout << "The graph is" << endl;
	L.Output();
	L.Delete(2,1);
	cout << "The graph after deleting <2,1> is" << endl;
	L.Output();
	cout << "Exist(3,1) = " << L.Exist(3,1) << endl;
	cout << "InDegree(3) = " << L.InDegree(3) << endl;
	cout << "OutDegree(1) = " << L.OutDegree(1) << endl;
	cout << "Edges = " << L.Edges() << endl;
	int i=1,j,c;
	L.InitializePos();
	try
	{
		L.First(i,j,c);
		L.DeactivatePos();
		cout<<i<<"->"<<j<<' '<<c<<endl;
	}
	catch(...)
	{
		cout<<"Failed!"<<endl;
	}
}

⌨️ 快捷键说明

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