本文整理汇总了C++中TGraph::Make_Tree方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::Make_Tree方法的具体用法?C++ TGraph::Make_Tree怎么用?C++ TGraph::Make_Tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph
的用法示例。
在下文中一共展示了TGraph::Make_Tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}