- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
最近我对节点编辑器很感兴趣,我指的是那些在 Maya 中看到和使用过的编辑器。 , Blender , Substance Painter , 以及 Unreal Engine 4 .
我的代码分为两部分,一部分处理 UI(创建节点、移动节点、附加节点),另一部分,我现在正在处理的是基本上读取图表的解释器。
这是显示三个由边连接的节点的屏幕截图(它们的方向总是这样:粉色 -> 绿色)。一个节点可以有多个参数(绿色停靠点)和多个返回值(绿色停靠点)。
需要说明的是,我有一个对象会在屏幕上发生变化时更新(节点连接、节点创建/删除)。我想创建一个算法来解释/读取图形,以便运行节点描述的程序。
我找到了 this reddit thread这有助于我理解这个问题。然而,我仍然没有足够的信心开始为它编写代码。
我假设需要有一个起始节点,用于启动图形读取的东西,但我面临的问题是当它变得更复杂时,例如具有多个输入节点的图形。
(下图有红色注释。)
最佳答案
关于节点图的更多细节:
绿色码头是来自其他节点的变量,因此它们是必然是前一个节点输出的对象。另一方面方形码头是常量。
我将引用“控制对象”,即保存图中停靠点之间所有链接的对象。
-- 算法开始 --
搜索所有输入节点,即所有左侧没有附加链接(无参数)的节点。
there are five on this graph: A, B, C, E, and K they have only constant docks on their left: A1, B1, B2, C1, E1, E2, K1, and K2 are all defined variables.
节点是函数,输入节点是没有参数的函数。不需要其他值,因此我们可以计算这五个节点的输出。
these outputs are A2, B3, C2, E3, E4, K3.
通过我们的控制对象,我们知道哪些扩展坞连接到这四个输出
they link like so: A2 -> D1; B3 -> D2; C2 -> D3; C2 -> F1; E3 -> G2; E4 -> J1; K3 -> N3
注意:链接到多个绿色停靠点的粉红色停靠点被处理为好像有多个相同的粉红色停靠点。例如,在这里,节点 C 的输出 C2 可以看作是 C2 和 C2'(因为 C2 链接到 D3 AND 到 F1)。总共有 7 个链接需要分析。
再次使用我们的控制对象,我们将查看这 7 个链接的最终位置。
they end in the D, F, G, J and N nodes
它们最终出现在五个不同的节点上。现在,我们可以计算出D输出、F输出、G输出、J输出和N输出吗?或者我们是否需要我们现在没有的其他变量?
node D has three parameters and it just happens that we have all three parameters: D1, D2, D3 so we can calculate D's output right now: D4 node F has only one parameter and we have F1, we can calculate F's output: F2 node G has two parameters but we only have G2, we can't calculate G's output => store G2 in G's waiting queue in the control object node J same thing we have J1 but not J2 => store J1 in J's waiting queue in the control object node N has three parameters but we only have N3
在此步骤结束时,我们计算了 D4 和 F2 并将以下值存储在我们的控制对象中:N3(尚未使用因为我们还没有 N1,N2),G2(因为我们没有 G1)和J1(因为我们没有 J2)。现在让我们看看 D4 和 F2 在哪里结束向上
D4 ends up on the G node: on the G1 dock (therefore the object in D4 dock equals the object in G1) F2 ends up on J node: on the J2 dock (same here)
我们可以计算出 G 和 J 吗?
for G we have 2 parameters on 2 so we can get G3 for J we have 2 parameters on 2 so we can get J3
检查 G3 和 J3 在哪里结束
H, I and L nodes
我们可以计算它们吗?
H has two parameters: H2 equal to G3 and the other one is set => we calculate H3 I has two parameters: I1 equal to G3 and the other one is set => we calculate I3 L has only one parameter: L1 => we calculate L2
H3、I3、L2 在哪里结束?
M and N
我们可以计算出 M 和 N 吗?
M has two parameters, we have M1 and M2 => we can calculate M3 N has three parameters, we have N3 from the first step stored in N's parameters array and N2 is equal to L2 => we cannot calculate N
我们还有一个顶点需要解决:M3
it goes to N, M3 = N1
我们可以计算 N 吗?
now we can because we have N1, N2, N3 => we can calculate node N (no output in this case)
没有更多的顶点需要排序
-- 算法结束 --
关于algorithm - 算法如何解释有向节点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45375932/
我在一本书(Interview Question)中读到这个问题,想在这里详细讨论这个问题。请点亮它。 问题如下:- 隐私和匿名化 马萨诸塞州集团保险委员会早在 1990 年代中期就有一个绝妙的主意
我最近接受了一次面试,面试官给了我一些伪代码并提出了相关问题。不幸的是,由于准备不足,我无法回答他的问题。由于时间关系,我无法向他请教该问题的解决方案。如果有人可以指导我并帮助我理解问题,以便我可以改
这是我的代码 public int getDist(Node root, int value) { if (root == null && value !=0) return
就效率而言,Strassen 算法应该停止递归并应用乘法的最佳交叉点是多少? 我知道这与具体的实现和硬件密切相关,但对于一般情况应该有某种指南或某人的一些实验结果。 在网上搜索了一下,问了一些他们认为
我想学习一些关于分布式算法的知识,所以我正在寻找任何书籍推荐。我对理论书籍更感兴趣,因为实现只是个人喜好问题(我可能会使用 erlang(或 c#))。但另一方面,我不想对算法进行原始的数学分析。只是
我想知道你们中有多少人实现了计算机科学的“ classical algorithms ”,例如 Dijkstra's algorithm或现实世界中的数据结构(例如二叉搜索树),而不是学术项目? 当有
我正在解决旧编程竞赛中的一些示例问题。在这个问题中,我们得到了我们有多少调酒师以及他们知道哪些食谱的信息。制作每杯鸡尾酒需要 1 分钟,我们需要使用所有调酒师计算是否可以在 5 分钟内完成订单。 解决
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我开始学习 Nodejs,但我被困在中间的某个地方。我从 npm 安装了一个新库,它是 express -jwt ,它在运行后显示某种错误。附上代码和错误日志,请帮助我! const jwt = re
我有一个证书,其中签名算法显示“sha256rsa”,但指纹算法显示“sha1”。我的证书 SHA1/SHA2 的标识是什么? 谢谢! 最佳答案 TL;TR:签名和指纹是完全不同的东西。对于证书的强度
我目前在我的大学学习数据结构类(class),并且在之前的类(class)中做过一些算法分析,但这是我在之前的类(class)中遇到的最困难的部分。我们现在将在我的数据结构类(class)中学习算法分
有一个由 N 个 1x1 方格组成的区域,并且该区域的所有部分都是相连的(没有任何方格无法到达的方格)。 下面是一些面积的例子。 我想在这个区域中选择一些方块,并且两个相邻的方块不能一起选择(对角接触
我有一些多边形形状的点列表,我想将其包含在我页面上的 Google map 中。 我已经从原始数据中删除了尽可能多的不必要的多边形,现在我剩下大约 12 个,但它们非常详细以至于导致了问题。现在我的文
我目前正在实现 Marching Squares用于计算等高线曲线,我对此处提到的位移位的使用有疑问 Compose the 4 bits at the corners of the cell to
我正在尝试针对给定算法的约束满足问题实现此递归回溯函数: function BACKTRACKING-SEARCH(csp) returns solution/failure return R
是否有包含反函数的库? 作为项目的一部分,我目前正在研究测向算法。我正在使用巴特利特相关性。在 Bartlett 相关性中,我需要将已经是 3 次矩阵乘法(包括 Hermitian 转置)的分子除以作
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 8 年前。 Improve
问题的链接是UVA - 1394 : And There Was One . 朴素的算法是扫描整个数组并在每次迭代中标记第 k 个元素并在最后停止:这需要 O(n^2) 时间。 我搜索了一种替代算法并
COM 中创建 GUID 的函数 (CoCreateGUID) 使用“分散唯一性算法”,但我的问题是,它是什么? 谁能解释一下? 最佳答案 一种生成 ID 的方法,该 ID 具有一定的唯一性保证,而不
在做一个项目时我遇到了这个问题,我将在这个问题的实际领域之外重新措辞(我想我可以谈论烟花的口径和形状,但这会使理解更加复杂).我正在寻找一种(可能是近似的)算法来解决它。 我有 n 个不同大小的容器,
我是一名优秀的程序员,十分优秀!