C++ 如何创建具有多个数据的节点的有向图?
我想创建一个带有节点和边的图,其中每个节点将包含C++ 如何创建具有多个数据的节点的有向图?,c++,graph,treenode,vertex,directed-graph,C++,Graph,Treenode,Vertex,Directed Graph,我想创建一个带有节点和边的图,其中每个节点将包含n个值。我们将得到起始节点的n值,我们需要从中生成其他节点,其中每个节点中的每个值的形式如下: t_n=t_(n-1)+2 或 生成此类节点时,应创建从旧节点到新节点的边 我知道这可能是一项非常琐碎的工作,但我的编程知识非常有限。我建议使用C++或结构中的类来表示节点。请帮助我创建具有多个值的节点的图,然后根据上述规则从父节点生成下一个节点。有些C++代码会很有帮助。 提前谢谢。但我并不完全理解你的任务 - graph with nodes an
n
个值。我们将得到起始节点的n
值,我们需要从中生成其他节点,其中每个节点中的每个值的形式如下:
t_n=t_(n-1)+2
或
生成此类节点时,应创建从旧节点到新节点的边
我知道这可能是一项非常琐碎的工作,但我的编程知识非常有限。我建议使用C++或结构中的类来表示节点。请帮助我创建具有多个值的节点的图,然后根据上述规则从父节点生成下一个节点。有些C++代码会很有帮助。
提前谢谢。但我并不完全理解你的任务
- graph with nodes and edges
- each node has n number of values
- we are given n values of the starting point
- need to generate other nodes where each value in each node would be either
- t_n=t_(n-1)+2
- t_n=t_(n-1)-1
- when such node is generated, it creates an edge from the old node to the new node.
这个起点:我们必须从它生成一个图吗?从旧节点和新节点创建边的过程是什么?这里的旧节点是起点吗
n个值是否表示点连接到的位置(作为该边连接到的其他边的链)?例如,为我们提供了一个具有数字链(6、4、5)的节点,这意味着我们需要生成额外的边,这些边将连接x次(第一条链接到起点的边将链接到6条边,其中一条边是起点)
当我有更多信息时,将编辑我的答案。你能在画图中画一个例子并上传到网上并提供链接吗?这更容易想象。刚刚注意到“有向图”。刚才我的眼睛滑过了。这意味着一条边可以指向多条其他边,而这些边不必指向此边。有趣。(我仍然需要更清楚地解释您的任务)
- graph with nodes and edges
- each node has n number of values
- we are given n values of the starting point
- need to generate other nodes where each value in each node would be either
- t_n=t_(n-1)+2
- t_n=t_(n-1)-1
- when such node is generated, it creates an edge from the old node to the new node.