c - 假设我们有一个包含节点和边的图,我们如何表示边列表。我不是在谈论邻接列表

标签 c list graph

什么是边列表?不是邻接列表.. 如果给定一个带有节点和边的图,我们如何在 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/

相关文章:

c - post_menu 段错误(核心转储)

python - 搜索文本中的单词,无论词形变化如何 : Python

python - string.join 使用元组或列表更快吗?

python - 如何在同一张图中绘制不同频率的各种数据?

algorithm - 关键路径与最长路径的关系

.pc 文件 "PCC-S-02015, unable to open include file"和 "PCC-S-02201, Encountered the symbol "size_t""的编译错误

c - 为什么这个 for 循环从一半开始而不打印出所有内容?

c - 缓冲区溢出时的段错误

python - Python 3.4 中可以选择迭代器的起点吗?

php - JpGraph:使用 AccBarPlot 时如何在 v3.5.0b1 中控制 x/y 偏移量、边距和颜色?