transitive-closure

Boost BGL Transitive reduction

♀尐吖头ヾ 提交于 2019-12-08 05:34:20
问题 I try to use the transitive_reduction of boost, but I don't know how to use it. I have a graph defined with : typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, IQsNode*> Graph; typedef Graph::vertex_descriptor Vertex; I would like to call the method : Graph TC; boost::transitive_reduction(_fullGraph, TC,g_to_tr_map_stor,g_to_tc_map_stor); I don't know the type I must use for "g_to_tr_map_stor" and "g_to_tc_map_stor". According with information i readed , it must

Prolog: check transitivity for simple facts

天大地大妈咪最大 提交于 2019-12-07 15:08:30
My intention was to implement a simple example (just for myself) of transitivity in Prolog. These are my facts: trust_direct(p1, p2). trust_direct(p1, p3). trust_direct(p2, p4). trust_direct(p2, p5). trust_direct(p5, p6). trust_direct(p6, p7). trust_direct(p7, p8). trust_direct(p100, p200). I've written this predicate to check whether A trusts C , which is true whenever there is a B that trusts C and A trusts this B : trusts(A, B) :- trust_direct(A, B). trusts(A, C) :- trusts(A, B), trusts(B, C). The predicate returns true for trusts(p1, p2) or trusts(p1, p5) for example, but trusts(p5, p6)

Boost BGL Transitive reduction

橙三吉。 提交于 2019-12-06 16:56:56
I try to use the transitive_reduction of boost, but I don't know how to use it. I have a graph defined with : typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, IQsNode*> Graph; typedef Graph::vertex_descriptor Vertex; I would like to call the method : Graph TC; boost::transitive_reduction(_fullGraph, TC,g_to_tr_map_stor,g_to_tc_map_stor); I don't know the type I must use for "g_to_tr_map_stor" and "g_to_tc_map_stor". According with information i readed , it must be a map from vertices to integers. I try many kind of map but without success. Some ideas ? Thx sehe As

Finding the transitive closure of a graph

青春壹個敷衍的年華 提交于 2019-12-06 09:13:02
I am trying to calculate a transitive closure of a graph. Let`s consider this graph as an example (the picture depicts the graph, its adjacency and connectivity matrix): Using Warshall's algorithm, which i found on this page, I generate this connectivity matrix (=transitive closure?), that is different from the one in the picture: 01111 01111 01011 01111 01111 I have also tried using this applet which also gives me a different result: 01111 01111 01111 01111 01111 So I'm a little confused right now, since I don't know which matrix is the right one. Can someone shed some light on my problem? C

How to express a transitive relationship

≡放荡痞女 提交于 2019-12-05 10:11:52
问题 I want to express a transitive relationship. If A references B and B references C then A references C. I have this: proj(A). proj(B). proj(C). ref(A,B). ref(B,C). When I query using proj(A) I obtain: [46] ?-proj(A). A = _639 What does "_639" mean? I expected a yes or no and got that strangeness. I need to add a rule to say: ref(A,C). and get YES. Ideally, if possible, I would like to show how this relationship came about: (A => B => C). 回答1: The _639 is an uninstantiated, anonymous variable.

How to express a transitive relationship

混江龙づ霸主 提交于 2019-12-03 21:38:08
I want to express a transitive relationship. If A references B and B references C then A references C. I have this: proj(A). proj(B). proj(C). ref(A,B). ref(B,C). When I query using proj(A) I obtain: [46] ?-proj(A). A = _639 What does "_639" mean? I expected a yes or no and got that strangeness. I need to add a rule to say: ref(A,C). and get YES. Ideally, if possible, I would like to show how this relationship came about: (A => B => C). The _639 is an uninstantiated, anonymous variable. Your "facts" have variables rather than atoms. For example: proj(A). % This has a variable A and means "any

Prolog graph path search with cyclic path

血红的双手。 提交于 2019-12-01 08:46:40
I am a complete newbie in Prolog. I am trying to figure out a problem where I need to check if path is present between edges. I am done with acyclic graph code for cyclic my code is going to infinite loop. path(Start, End) :- edge(Start, End). path(Start, End) :- edge(Start, Z), path(Z, End). I need to handle this case by defining a new predicate: new_path(Start,End,path) which should eliminate infinite loop. Please let me know how to proceed with it. false Try path(Start, End) :- closure(edge, Start, End). using this definition for closure/3 Nicholas Carey You need to keep track of what nodes

transitive closure over a symmetric relation in prolog

最后都变了- 提交于 2019-12-01 07:40:19
I am a prolog beginner and I want to create the "brother" relation. The relation should be symmetric as in if brother(alin, alex) is true, brother(alex, alin) should be as well. It should also be transitive as in if brother(alin, alex) and brother(alex, claudiu) are true, brother(alin, claudiu) should be as well. Combining the to properties, if brother(alex, alin) and brother(alex, claudiu) are true, brother(alin, claudiu) should also be true. Here is my code: r_brother(alin, alex). r_brother(alin, ciprian). r_brother(alex, claudiu). s_brother(X, Y) :- r_brother(X, Y). s_brother(X, Y) :- r

Prolog graph path search with cyclic path

帅比萌擦擦* 提交于 2019-12-01 07:04:36
问题 I am a complete newbie in Prolog. I am trying to figure out a problem where I need to check if path is present between edges. I am done with acyclic graph code for cyclic my code is going to infinite loop. path(Start, End) :- edge(Start, End). path(Start, End) :- edge(Start, Z), path(Z, End). I need to handle this case by defining a new predicate: new_path(Start,End,path) which should eliminate infinite loop. Please let me know how to proceed with it. 回答1: Try path(Start, End) :- closure(edge

transitive closure over a symmetric relation in prolog

北慕城南 提交于 2019-12-01 05:01:37
问题 I am a prolog beginner and I want to create the "brother" relation. The relation should be symmetric as in if brother(alin, alex) is true, brother(alex, alin) should be as well. It should also be transitive as in if brother(alin, alex) and brother(alex, claudiu) are true, brother(alin, claudiu) should be as well. Combining the to properties, if brother(alex, alin) and brother(alex, claudiu) are true, brother(alin, claudiu) should also be true. Here is my code: r_brother(alin, alex). r_brother