:- module graph. :- use_module builtin, int, list, map, private_builtin, require, set, std_util. :- type (graph:node_supply) == int. :- type (graph:node(N)) ---> node(int) . :- type (graph:graph(N, A)) ---> graph(int, int, (tree234:tree234((graph:node(N)), N)), (tree234:tree234((graph:arc(A)), (graph:arc_info(N, A)))), (tree234:tree234((graph:node(N)), (tree234:tree234((graph:arc(A)), (graph:node(N))))))) . :- type (graph:arc_supply) == int. :- type (graph:arc_info(N, A)) ---> arc_info((graph:node(N)), (graph:node(N)), A) . :- type (graph:arc(A)) ---> arc(int) . :- pred graph:select_node((tree234:tree234((graph:node(N_1)), N_1)), N_1, (graph:node(N_1))). :- mode graph:select_node((builtin:in), (builtin:in), (builtin:out)) is nondet. :- pred graph:path_2((graph:graph(N_1, A_2)), (graph:node(N_1)), (graph:node(N_1)), (list:list((graph:node(N_1)))), (list:list((graph:arc(A_2))))). :- mode graph:path_2((builtin:in), (builtin:in), (builtin:in), (builtin:in), (builtin:out)) is nondet. :- mode graph:path_2((builtin:in), (builtin:in), (builtin:out), (builtin:in), (builtin:out)) is nondet. :- pred graph:get_nodes((graph:graph(N_1, A_2)), (tree234:tree234((graph:node(N_1)), N_1))). :- mode graph:get_nodes((builtin:in), (builtin:out)) is det. :- pred graph:get_arcs((graph:graph(N_1, A_2)), (tree234:tree234((graph:arc(A_2)), (graph:arc_info(N_1, A_2))))). :- mode graph:get_arcs((builtin:in), (builtin:out)) is det. :- pred graph:get_edges((graph:graph(N_1, A_2)), (tree234:tree234((graph:node(N_1)), (tree234:tree234((graph:arc(A_2)), (graph:node(N_1))))))). :- mode graph:get_edges((builtin:in), (builtin:out)) is det. graph:init = G_2 :- graph:init(G_2). graph:search_node(Graph_4, NodeInfo_5, Node_6) :- graph:get_nodes(Graph_4, NodeTable_7), map:member(NodeTable_7, Node_6, NodeInfo_5). graph:find_matching_nodes(Graph_4, NodeInfo_5, NodeSet_6) :- graph:get_nodes(Graph_4, NodeTable_7), V_9 = graph:select_node(NodeTable_7, NodeInfo_5), std_util:solutions(V_9, NodeList_8), set:sorted_list_to_set(NodeList_8, NodeSet_6). graph:find_matching_nodes(G_4, N_5) = S_6 :- graph:find_matching_nodes(G_4, N_5, S_6). graph:node_contents(G_4, N_5, I_6) :- graph:get_nodes(G_4, Ns_7), map:lookup(Ns_7, N_5, I_6). graph:node_contents(G_4, N_5) = NI_6 :- graph:node_contents(G_4, N_5, NI_6). graph:successors(G_4, N_5, Ss_6) :- graph:get_edges(G_4, Es_7), map:lookup(Es_7, N_5, E_8), map:values(E_8, SsList_9), set:list_to_set(SsList_9, Ss_6). graph:successors(G_4, N_5) = S_6 :- graph:successors(G_4, N_5, S_6). graph:nodes(G_3, Ns_4) :- graph:get_nodes(G_3, Ns0_5), map:keys(Ns0_5, Ns1_6), set:list_to_set(Ns1_6, Ns_4). graph:nodes(G_3) = S_4 :- graph:nodes(G_3, S_4). graph:arc_contents(G_6, N_7, S_8, E_9, A_10) :- graph:get_arcs(G_6, Ns_11), map:lookup(Ns_11, N_7, I_12), I_12 = graph:arc_info(S_8, E_9, A_10). graph:path(G_5, S_6, E_7, Path_8) :- V_9 = list:[], graph:path_2(G_5, S_6, E_7, V_9, Path_8). graph:select_node(NodeTable_4, NodeInfo_5, Node_6) :- map:member(NodeTable_4, Node_6, NodeInfo_5). graph:get_nodes(G_3, N_4) :- G_3 = graph:graph(_NS_5, _AS_6, N_4, _A_7, _E_8). graph:get_arcs(G_3, A_4) :- G_3 = graph:graph(_NS_5, _AS_6, _N_7, A_4, _E_8). graph:get_edges(G_3, E_4) :- G_3 = graph:graph(_NS_5, _AS_6, _N_7, _A_8, E_4). :- pragma termination_info(graph:init((builtin:out)), infinite, can_loop). :- pragma termination_info((graph:init) = (builtin:out), infinite, can_loop). :- pragma termination_info(graph:set_node((builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:insert_node((builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:det_insert_node((builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:search_node((builtin:in), (builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:find_matching_nodes((builtin:in), (builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:find_matching_nodes((builtin:in), (builtin:in)) = (builtin:out), infinite, can_loop). :- pragma termination_info(graph:node_contents((builtin:in), (builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:node_contents((builtin:in), (builtin:in)) = (builtin:out), infinite, can_loop). :- pragma termination_info(graph:successors((builtin:in), (builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:successors((builtin:in), (builtin:in)) = (builtin:out), infinite, can_loop). :- pragma termination_info(graph:nodes((builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:nodes((builtin:in)) = (builtin:out), infinite, can_loop). :- pragma termination_info(graph:set_edge((builtin:in), (builtin:in), (builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:insert_edge((builtin:in), (builtin:in), (builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:det_insert_edge((builtin:in), (builtin:in), (builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:arc_contents((builtin:in), (builtin:in), (builtin:out), (builtin:out), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:path((builtin:in), (builtin:in), (builtin:in), (builtin:out)), infinite, can_loop). :- pragma termination_info(graph:path((builtin:in), (builtin:in), (builtin:out), (builtin:out)), infinite, can_loop).