基于DAG的应用

发布于 2024-08-17 03:07:48 字数 748 浏览 5 评论 0原文

前几天我无法正确表达自己并关闭我的答案,所以这是我的第二个镜头:

我需要创建一个基本的 DAG(有向无环图)应用程序,放在常见的单词上,一个基于节点的应用程序。我不需要 nw 的 GUI,只需要一个执行整个树的控制台示例。

到目前为止,这就是我所拥有的:

 typedef struct Node
 {
  int type;
  void ( *excecute)(); //the callback function

  struct Node *ins;
  struct Node *outs;

  }

 //some functions

void root(float n,float *buffer)
{
 buffer[0]=sqrtf(n);
 }

void sum(float a, float b, float *buffer)
{
  buffer[0]=a+b;
}

void Output_screen(float val)
{
printf(""The DAG output is: %f ", val);
}

节点可以有任意数量的输入和任意数量的输出(我如何处理它们?)

我的问题是: 如何构建一个 DAG,其中节点 sum 的输出为节点根的输入,该输出为节点 Output_screen 的输入?

节点(总和)--->节点(根)--->节点(Output_screen)

我会提供任何帮助,因为我找不到任何关于它的帮助

the other day I could not exprese myself correctly and get closed my answer, so here's my second shot:

I need to create a basic DAG (Directed Acyclic Graph) application, put on common words, a node based application. I don't need a GUI for nw, just a console example, that excecute the whole tree.

here's what I have so far :

 typedef struct Node
 {
  int type;
  void ( *excecute)(); //the callback function

  struct Node *ins;
  struct Node *outs;

  }

 //some functions

void root(float n,float *buffer)
{
 buffer[0]=sqrtf(n);
 }

void sum(float a, float b, float *buffer)
{
  buffer[0]=a+b;
}

void Output_screen(float val)
{
printf(""The DAG output is: %f ", val);
}

The nodes could have any number of inputs and any umber of outputs (how do i handle them?)

My question is:
How do I construct a DAG with the output of a node sum be the input of a node root and that output be the input of the node Output_screen?

Node(sum)---> Node(root)--->Node(Output_screen)

I will preciate any help, since I could'nt find any tut on it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唐婉 2024-08-24 03:07:48

你需要的是高德纳的一本。我强烈推荐阅读他的文章来了解这种基本数据结构。

除此之外,您可以使用链接列表来表示节点列表。如果您使用 C++,您还可以使用指针的 STL 向量。

What you need is a copy of Knuth. I cannot recommend strongly enough reading him to learn about this kind of basic data structure.

Aside from which, you could use linked lists to represent the node lists. If you are in C++, you can also use STL vectors of pointers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文