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

📄 bayers.cpp

📁 bayes network 的分三角形的算法
💻 CPP
字号:
// Bayers.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "Graph.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	Graph graph;
	int nodeNumber;
	int edgeNumberMax;
	int from,to;

	//设置总节点数
	cout<<"请输入节点总数:";
	cin>>nodeNumber;
	graph.Create(nodeNumber);
	//设置节点信息
	for(int i=0;i<nodeNumber;i++)
	{
		GraphNode node;
		cout<<"请输入第"<<i<<"个顶点的信息。"<<endl;
		cout<<"顶点编号:"<<i<<endl;
		node.ID=i;
		cout<<"顶点名称:";
		cin>>node.name;
		cout<<"顶点权重:";
		cin>>node.weight;
		//添加节点
		graph.AddNode(node,i);
	}
	//添加节点之间关系
	cout<<"开始输入节点之间关系"<<endl;
	edgeNumberMax=nodeNumber*(nodeNumber-1);
	for(int i=0;i<edgeNumberMax;i++)
	{
		cout<<"请输入源节点编号:";
		cin>>from;
		cout<<"请输入目的节点编号:";
		cin>>to;
		graph.AddRelationship(from,to);

		//判断是否还要输入
		char flag;
		cout<<"是否还要继续输入?(y/n)";
RE:		cin>>flag;
		if('n'==flag || 'N'==flag)
			break;
		else if('y'==flag || 'Y'==flag)
			continue;
		else
		{
			cout<<"请输入y(Y)或者n(N)):";
			goto RE;
		}
	}
	
	//graph.Dump();
	//cout<<endl;
	Graph::TriGraph g(graph.Triangulate());
	//查看图的内存信息
	//graph.Dump();
	cout<<endl;
	for(int itr=0;itr<g.length;itr++)
	{
		cout<<"第"<<itr<<"个簇:"<<endl;
		g[itr].Dump();
	}

	system("Pause");
	return 0;
}

⌨️ 快捷键说明

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