什么是边列表?不是邻接列表.. 如果给定一个带有节点和边的图,我们如何在 C 编程中表示边列表?
最佳答案
这是基本结构
struct Edge
{
int id;
int weight; // If you need one
vector<Edge *> neighbours; // List of references on your neightbours
}
vector<Edge> graph;
但是正如 Michael 所注意到的,它看起来确实像是一项家庭作业:) 看看启动图表库。
更新C版本
struct Edge
{
int id;
int weight; // If you need one
Edge *next; // Next edge in the list
Edge *neighbours; // List of neightbours
}
Edge *graph;
关于c - 假设我们有一个包含节点和边的图,我们如何表示边列表。我不是在谈论邻接列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4726274/