5.49. balance_tree

DESCRIPTIONLINKSGRAPH
Origin

derived from πš‹πšŠπš•πšŠπš—πšŒπšŽ and πšπš›πšŽπšŽ

Constraint

πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ(𝙱𝙰𝙻𝙰𝙽𝙲𝙴,π™½π™Ύπ™³π™΄πš‚)

Arguments
π™±π™°π™»π™°π™½π™²π™΄πšπšŸπšŠπš›
π™½π™Ύπ™³π™΄πš‚πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš’πš—πšπšŽπš‘-πš’πš—πš,𝚜𝚞𝚌𝚌-πšπšŸπšŠπš›)
Restrictions
𝙱𝙰𝙻𝙰𝙽𝙲𝙴β‰₯0
π™±π™°π™»π™°π™½π™²π™΄β‰€πš–πšŠπš‘(0,|π™½π™Ύπ™³π™΄πš‚|-2)
πš›πšŽπššπšžπš’πš›πšŽπš(π™½π™Ύπ™³π™΄πš‚,[πš’πš—πšπšŽπš‘,𝚜𝚞𝚌𝚌])
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰₯1
π™½π™Ύπ™³π™΄πš‚.πš’πš—πšπšŽπš‘β‰€|π™½π™Ύπ™³π™΄πš‚|
πšπš’πšœπšπš’πš—πšŒπš(π™½π™Ύπ™³π™΄πš‚,πš’πš—πšπšŽπš‘)
π™½π™Ύπ™³π™΄πš‚.𝚜𝚞𝚌𝚌β‰₯1
π™½π™Ύπ™³π™΄πš‚.πšœπšžπšŒπšŒβ‰€|π™½π™Ύπ™³π™΄πš‚|
Purpose

Consider a digraph G described by the π™½π™Ύπ™³π™΄πš‚ collection. Partition G into a set of vertex disjoint trees in such a way that each vertex of G belongs to a single tree. 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 is equal to the difference between the number of vertices of the largest tree and the number of vertices of the smallest tree.

Example
4,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-5,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-5,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-7,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-6𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-7𝚜𝚞𝚌𝚌-7,πš’πš—πšπšŽπš‘-8𝚜𝚞𝚌𝚌-5
2,πš’πš—πšπšŽπš‘-1𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-2𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-3𝚜𝚞𝚌𝚌-1,πš’πš—πšπšŽπš‘-4𝚜𝚞𝚌𝚌-2,πš’πš—πšπšŽπš‘-5𝚜𝚞𝚌𝚌-6,πš’πš—πšπšŽπš‘-6𝚜𝚞𝚌𝚌-6

In the first example we have two trees involving respectively the set of vertices {1,2,3,5,6,8} and the set {4,7}. They are depicted by FigureΒ 5.49.1. Since 𝙱𝙰𝙻𝙰𝙽𝙲𝙴=6-2=4 is the difference between the number of vertices of the largest tree (i.e.,Β 6) and the number of vertices of the smallest tree (i.e.,Β 2) the corresponding πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ constraint holds.

Figure 5.49.1. The two trees associated with the first example of the Example slot, respectively containing 6 and 2 vertices, therefore 𝙱𝙰𝙻𝙰𝙽𝙲𝙴=6-2=4; each vertex contains the information πš’πš—πšπšŽπš‘|𝚜𝚞𝚌𝚌 where 𝚜𝚞𝚌𝚌 is the index of its father in the tree (by convention the father of the root is the root itself).
ctrs/balance_tree-1-tikz
All solutions

FigureΒ 5.49.2 gives all solutions to the following non ground instance of the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ constraint: 𝙱𝙰𝙻𝙰𝙽𝙲𝙴=0, S 1 ∈[1,2], S 2 ∈[1,2], S 3 ∈[4,5], S 4 ∈[2,4], S 5 ∈[4,5], S 6 ∈[5,6], πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ(𝙱𝙰𝙻𝙰𝙽𝙲𝙴,〈1 S 1 ,2 S 2 ,3 S 3 ,4 S 4 ,5 S 5 ,6 S 6 βŒͺ).

Figure 5.49.2. All solutions corresponding to the non ground example of the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ constraint of the All solutions slot; the πš’πš—πšπšŽπš‘ attribute is displayed as indices of the 𝚜𝚞𝚌𝚌 attribute and all vertices of a same tree are coloured by the same colour.
ctrs/balance_tree-2-tikz
Typical
|π™½π™Ύπ™³π™΄πš‚|>2
Symmetry

Items of π™½π™Ύπ™³π™΄πš‚ are permutable.

Arg. properties

Functional dependency: 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 determined by π™½π™Ύπ™³π™΄πš‚.

Counting
Length (n)2345678
Solutions3161251296168072621444782969

Number of solutions for πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ: domains 0..n

ctrs/balance_tree-3-tikz

ctrs/balance_tree-4-tikz

Length (n)2345678
Total3161251296168072621444782969
Parameter
value

03107762687071176502242193
1-6122602102524249616
2--369031809765432264
3---32096041930219520
4----375013125680456
5-----54432217728
6------941192

Solution count for πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ: domains 0..n

ctrs/balance_tree-5-tikz

ctrs/balance_tree-6-tikz

See also

implied by: πš‹πšŠπš•πšŠπš—πšŒπšŽ_πš™πšŠπšπš‘.

related: πš‹πšŠπš•πšŠπš—πšŒπšŽΒ (equivalence classes correspond to vertices in same tree rather than variables assigned to the same value), πšπš›πšŽπšŽΒ (do not care how many trees but how balanced the trees are).

Keywords

constraint type: graph constraint, graph partitioning constraint.

filtering: DFS-bottleneck.

final graph structure: connected component, tree, one_succ.

modelling: functional dependency.

Cond. implications

πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ(𝙱𝙰𝙻𝙰𝙽𝙲𝙴,π™½π™Ύπ™³π™΄πš‚)

Β Β Β  withΒ  𝙱𝙰𝙻𝙰𝙽𝙲𝙴>0

Β Β Β  andΒ Β  𝙱𝙰𝙻𝙰𝙽𝙲𝙴≀|π™½π™Ύπ™³π™΄πš‚|

Β Β implies πš˜πš›πšπšŽπš›πšŽπš_πšŠπšπš•πšŽπšŠπšœπš_πš—πšŸπšŽπšŒπšπš˜πš›(π™½πš…π™΄π™²:𝙱𝙰𝙻𝙰𝙽𝙲𝙴,πš…π™΄π™²πšƒπ™Ύπšπš‚:π™½π™Ύπ™³π™΄πš‚).

Arc input(s)

π™½π™Ύπ™³π™΄πš‚

Arc generator
πΆπΏπΌπ‘„π‘ˆπΈβ†¦πšŒπš˜πš•πš•πšŽπšŒπšπš’πš˜πš—(πš—πš˜πšπšŽπšœ1,πš—πš˜πšπšŽπšœ2)

Arc arity
Arc constraint(s)
πš—πš˜πšπšŽπšœ1.𝚜𝚞𝚌𝚌=πš—πš˜πšπšŽπšœ2.πš’πš—πšπšŽπš‘
Graph property(ies)
β€’ πŒπ€π—_𝐍𝐒𝐂𝐂≀1
β€’ 𝐑𝐀𝐍𝐆𝐄_𝐍𝐂𝐂=𝙱𝙰𝙻𝙰𝙽𝙲𝙴

Graph model

In order to express the binary constraint that links two vertices one has to make explicit the identifier of the vertices. This is why the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ constraint considers objects that have two attributes:

  • One fixed attribute πš’πš—πšπšŽπš‘ that is the identifier of the vertex,

  • One variable attribute 𝚜𝚞𝚌𝚌 that is the successor of the vertex.

We use the graph property πŒπ€π—_𝐍𝐒𝐂𝐂≀1 in order to specify the fact that the size of the largest strongly connected component should not exceed one. In fact each root of a tree is a strongly connected component with a single vertex.

PartsΒ (A) andΒ (B) of FigureΒ 5.49.3 respectively show the initial and final graph associated with the first example of the Example slot. Since we use the 𝐑𝐀𝐍𝐆𝐄_𝐍𝐂𝐂 graph property, we show the connected components of the final graph. The constraint holds since all the vertices belong to a tree and since 𝙱𝙰𝙻𝙰𝙽𝙲𝙴 = 𝐑𝐀𝐍𝐆𝐄_𝐍𝐂𝐂6-2=4.

Figure 5.49.3. Initial and final graph of the πš‹πšŠπš•πšŠπš—πšŒπšŽ_πšπš›πšŽπšŽ constraint
ctrs/balance_treeActrs/balance_treeB
(a) (b)