|
| 1 | +include "fzn_cluster_int.mzn"; |
| 2 | +include "fzn_cluster_int_reif.mzn"; |
| 3 | +include "fzn_cluster_enum.mzn"; |
| 4 | +include "fzn_cluster_enum_reif.mzn"; |
| 5 | + |
| 6 | +/** @group globals.graph |
| 7 | + Clusterize the subgraph \a ns and \a es of a given undirected graph into disjoint subgraphs, |
| 8 | + and produce a \a r node reachability matrix. |
| 9 | +
|
| 10 | + @param N: the number of nodes in the given graph |
| 11 | + @param E: the number of edges in the given graph |
| 12 | + @param from: the leaving node 1..\a N for each edge |
| 13 | + @param to: the entering node 1..\a N for each edge |
| 14 | + @param r: node reachability matrix |
| 15 | + @param ns: a Boolean for each node whether it is in the subgraph |
| 16 | + @param es: a Boolean for each edge whether it is in the subgraph |
| 17 | +*/ |
| 18 | +predicate cluster(int: N, int: E, array[int] of int: from, array[int] of int: to, |
| 19 | + array[int,int] of var bool: r, |
| 20 | + array[int] of var bool: ns, array[int] of var bool: es) = |
| 21 | + assert(index_set(from) = 1..E,"cluster: index set of from must be 1..\(E)") /\ |
| 22 | + assert(index_set(to) = 1..E,"cluster: index set of to must be 1..\(E)") /\ |
| 23 | + assert(index_set(ns) = 1..N,"cluster: index set of ns must be 1..\(N)") /\ |
| 24 | + assert(index_set(es) = 1..E,"cluster: index set of es must be 1..\(E)") /\ |
| 25 | + fzn_cluster(N,E,from,to,r,ns,es); |
| 26 | + |
| 27 | +/** @group globals.graph |
| 28 | + Clusterize the subgraph \a ns and \a es of a given undirected graph into disjoint subgraphs, |
| 29 | + and produce a \a r node reachability matrix. |
| 30 | +
|
| 31 | + @param from: the leaving node for each edge |
| 32 | + @param to: the entering node for each edge |
| 33 | + @param r: node reachability matrix |
| 34 | + @param ns: a Boolean for each node whether it is in the subgraph |
| 35 | + @param es: a Boolean for each edge whether it is in the subgraph |
| 36 | +*/ |
| 37 | +predicate cluster(array[$$E] of $$N: from, array[$$E] of $$N: to, |
| 38 | + array[$$N,$$N] of var bool: r, |
| 39 | + array[$$N] of var bool: ns, array[$$E] of var bool: es) = |
| 40 | + let { |
| 41 | + int: NUM_NODES = card(index_set(ns)); |
| 42 | + } in |
| 43 | + assert(index_set(from) = index_set(to),"cluster: index set of from and to must be identical") /\ |
| 44 | + assert(index_set(from) = index_set(es),"cluster: index set of from and es must be identical") /\ |
| 45 | + assert(index_set_1of2(r) = index_set_2of2(r),"cluster: nodes in from must be in index set of r") /\ |
| 46 | + assert(dom_array(from) subset index_set_1of2(r),"cluster: nodes in from must be in index set of r") /\ |
| 47 | + assert(dom_array(to) subset index_set_1of2(r),"cluster: nodes in to must be in index set of r") /\ |
| 48 | + assert(dom_array(from) subset index_set(ns),"cluster: nodes in from must be in index set of ns") /\ |
| 49 | + assert(dom_array(to) subset index_set(ns),"cluster: nodes in to must be in index set of ns") /\ |
| 50 | + fzn_cluster(from,to,r,ns,es); |
0 commit comments