开发者

PROLOG / All paths in a directed graph with loops

I've got the following diagram given:

Diagram here

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜