【发布时间】:2013-05-01 08:22:02
【问题描述】:
我已经制作了以下节点和弧结构:
struct arc
{
int length;
string start;
string end;
arc(int k,string s,string e)
{
this->length = k;
this->start = s;
this->end = e;
}
};
struct node
{
string name;
double x;
double y;
vector<arc> link;
node(string n,double xx,double yy)
{
this->name = n;
this->x = xx;
this->y = yy;
}
};
现在我想创建一个图形数据结构,以便能够在其上实现 Kruskal 算法。 我无法理解如何利用这两个结构。 每个节点都存储其名称和坐标以及有关往返于它的弧的信息。 所以我有一个节点集群,但我如何将所有东西链接在一起。这里没有根节点。我应该在我的图表类中添加什么? 我已经搜索了邻接列表和矩阵,但无法理解如何将我的想法与它们联系起来?请解释一下
【问题讨论】:
标签: graph nodes kruskals-algorithm