当前位置: 首页>>代码示例>>C++>>正文


C++ TGraph::Add方法代码示例

本文整理汇总了C++中TGraph::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::Add方法的具体用法?C++ TGraph::Add怎么用?C++ TGraph::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TGraph的用法示例。


在下文中一共展示了TGraph::Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;

	TGraph Graph (n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			bool x;
			cin >> x;
			if (x)
				Graph.Add(i, j);
		}
	
	bool ok = true;
	for (int i = 0; i < n; i++)
		if (!Graph.Used[i])
			Graph.DFS ( i, ok );

	if (ok)
		cout << "YES\n";

	fclose(stdin);
	fclose(stdout);

	return 0;
}
开发者ID:kamiltalipov,项目名称:295-a2,代码行数:30,代码来源:main.cpp

示例2: main

int main()
{
	freopen ("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);

	srand((unsigned)time(0));
	double n, m;
	double s1, s2;
	vector < pair < double, double > > center;
	vector < pair < double, double > > points;
	cin >> n >> m;
	cin >> s1 >> s2;
	
	TGraph Graph (n, m);
	TDSU DSU(n, m);

	for (int i = 0; i < n; i++)
		center.push_back( Box_Muller( 0, 0, s1 ) );

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			pair < double, double > tmp = Box_Muller ( center[i].first, center[i].second, s2 );
			points.push_back( tmp );
		}

	for (int i = 0; i < n * m; i++)
		for (int j = 0; j < n * m; j++)
			if (i != j)
				Graph.Add( i, j, dist( points[i], points[j] ) );
			
	sort(Graph.Vert.begin(), Graph.Vert.end());
	Graph.Make_Tree( DSU );

	Graph.Commie(0);
	Graph.Path.push_back( make_pair ( Graph.Path.back().second, 0) );

	double weight = 0;
	for (int i = 0; i < Graph.Path.size(); i++)
	{
		int v = Graph.Path[i].first;
		int u = Graph.Path[i].second;
		cout << points[v].first << ' ' << points[v].second << " : " << points[u].first << ' ' << points[u].second << endl;
		weight += dist ( points[v], points[u] );
	}

	cout << endl << weight << endl;

	fclose(stdin);
	fclose(stdout);
	return 0;
}
开发者ID:kamiltalipov,项目名称:295-a2,代码行数:52,代码来源:main.cpp


注:本文中的TGraph::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。