My first attempt was successful. ----- graph_1.ecl % Run in this way: top(Path). /* Results: ?- top(Path). Path = 2 - [e(7, 5, 1), e(1, 7, 1)] Yes (0.00s cpu) (The shortest path is returned as a Length-EdgeList structure where Length is the length of the shortest path and EdgeList is that path (or one of them) in reverse order, i.e. starting with the edge reaching SinkNode and ending with the edge starting from SourceNode.) */ :-lib(ic). :-lib(graph_algorithms). top(Path) :- make_graph( 13, [ e(1,6,1),e(1,2,1),e(1,7,1),e(3,1,1),e(4,6,1),e(5,4,1), e(6,5,1),e(7,5,1),e(7,10,1),e(7,3,1),e(8,7,1),e(8,9,1),e(9,8,1), e(10,11,1),e(10,12,1),e(10,13,1),e(12,7,1),e(12,13,1),e(13,12,1) ], Graph), single_pair_shortest_path(Graph,-1,1,5,Path). ----- My second attempt caused an error. ----- graph_2.ecl % Run in this way: top(Path). /* Results: ?- top(Path). Abort number expected in arg(a, [](_806, _807, _808, _809, _810, _811, _812, _813, _814, _815, _816, _817, _818), _822) */ :-lib(ic). :-lib(graph_algorithms). top(Path) :- make_graph_symbolic( [](a,b,c,d,e,f,g,h,i,j,k,l,m), [ edge(a,f,1),edge(a,b,1),edge(a,g,1),edge(c,a,1),edge(d,f,1),edge(e,d,1), edge(f,e,1),edge(g,e,1),edge(g,j,1),edge(g,c,1),edge(h,g,1),edge(h,i,1),edge(i,h,1), edge(j,k,1),edge(j,l,1),edge(j,m,1),edge(l,g,1),edge(l,m,1),edge(m,l,1) ], Graph), single_pair_shortest_path(Graph,-1,a,e,Path). ----- (I know now that SourceNode is the source node number (integer) and SinkNode is the sink node number (integer) in the single_pair_shortest_path predicate.) How does one use the make_graph_symbolic predicate in the same program as the single_pair_shortest_path predicate?Received on Mon Oct 07 2013 - 20:30:17 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST