PROLOG / 带循环的有向图中的所有路径
我给出了下图:
第一个网关/连接器是 OR 网关/连接器(其中有一个圆圈)。带有“x”的网关/连接器是异或网关/连接器。
OR 网关指定将采用一条或多条可用路径。 XOR 网关代表在流中仅采用一条路径的决定。
我需要将此图转换为 PROLOG,以便获得从节点 1 到节点 8 的所有可能路径,但我在编写 OR 网关并查找所有可能路径时遇到问题。
我如何才能轻松地将这个图转换为 Prolog,以及如何找到有关两个节点之间的网关的所有可能路径?
感谢您提前的答复。
I've got the following diagram given:
The first gateway/connector is an OR-gateway/connector (it has a circle in it). The gateway/connector with a 'x' in it is a XOR-gateway/connector.
An OR-gateway specifies that one or more of the available paths will be taken.
An XOR-gateway represents a decision to take exactly one path in the flow.
I need to transform this diagram to PROLOG in order to get all possible paths from node 1 to node 8 but I have problems to code the OR-gateway and to find all possible paths.
How can I transform this diagram easily to Prolog and how can i find all possible paths respecting the gateways between two nodes?
Thank you for answers in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您应该知道的,Prolog 程序基本上是一组规则。从你的图中,每个节点都可以开始一个规则,其中每个有向边给出一个明确的规则。通过将图编码为一组规则,查询满足(1,X,8)的内容,将为您提供所有可能的路径,甚至是无限的路径。
对规则进行编码应该很容易(基本的 Prolog)。也许我不理解 OR 和 XOR 背后的特殊功能。如果这并不像看起来那么微不足道,请解释更多。
As you should know, a Prolog program is basically a set of rules. From your graph, each node could begin a rule where each directed edge gives an explicit rule. By encoding your graph as a set of rules, a query on what satisfies say, (1, X, 8), would give you every possible path, even infinitely.
Encoding the rules should be easy (basic Prolog). Maybe I'm not understanding the special functions behind the OR and XOR. Please explain more if this isn't as trivial as it seems.