【发布时间】:2020-02-04 03:14:00
【问题描述】:
该示例被简化为一个玩具示例,但我将处理 1000 个节点。
我们有 5 个节点
t1
t2
a0
a1
t1 connects to a0 and a3
t2 connects to a0, a1, a2 and a3
a0 connects to a1
a1 connects to a0, t2
我的最终目标是制作一个程序,该程序将绘制节点之间的连接以及使用图形库的节点。
我可以使用什么样的数据结构。我的第一个想法是使用链表,但我认为这不适用于这种情况,因为该数据结构仅在每个节点之间使用一个连接。
【问题讨论】:
-
听起来
std::map<std::string, std:vector>是一个不错的起点。您也可以将其实现为指针链接节点,其中每个节点都有一个std::vector<Node*>类型的东西。
标签: c++ arrays arraylist data-structures