Question-related definitions:
(1) triangular subdivision of convex polygon : A set of chords that divides a convex polygon into a disjoint triangle.
(2) Optimal split : A given convex polygon p, and a weight function w defined on a triangle that consists of a polygon's edge chord. It is required to determine the triangulation of the convex polygon, so that the sum of the weights in the triangles is minimized. To split the case.
If Convex (n+1) edge shape p={v0,v1 ... VThe optimal triangulation t of n} contains the triangle V0VKVn, 1<=k<=n, then the right of T is three parts of the sum: Triangle v0vkvn right, polygon {v0 , V1... Vk} right and polygon {vk, vk+1... the sum of the weights of V n}. As shown in the following:
It can be asserted that the triangulation of the two sub-polygons determined by T is also optimal. Because if there is {v0, v1... Vk} and {v0, v1... VK} The triangulation of the smaller right will cause t not the contradiction of optimal triangulation. Therefore, the triangulation problem of convex polygon has the optimal substructure property.
3. Recurrence Relationship:
set T[i][j],1<=i<j<=n to convex polygon {Vi-1,vi ... Thevalue of the weighted function corresponding to the optimal triangulation of V J}, i.e. its optimal value. The optimal subdivision containsthe right of the triangle V i-1v KV J, the sub-polygon {vi-1,vi ... the right of V K}, sub-polygon {Vk,vk+1 ... the sum of the rights of V J}.
Therefore, you can get a recursive relationship:
The optimal weight value of the convex (n+1) Edge P is t[1][n].
Excerpt from:http://blog.csdn.net/liufeng_king/article/details/8639376
The structure of triangulation and its related problems.
The triangulation of a convex triangle is closely related to the complete parentheses of the expression. As you can see, the optimal order of the matrix multiplication is equivalent to the optimal complete parenthesis of the matrix chain. What's even more fascinating is that these problems seem to be carved out of a mold! The essential reason is that they correspond to the isomorphism of the complete binary tree. The full parenthesis of an expression corresponds to a complete binary tree, which is called the syntax tree of the expression. And exactly, the subdivision of a convex polygon can also be expressed in grammatical numbers. (Please forgive the "Cao Tan") Drawing Kung Fu, unable to draw the corresponding picture.
Template Main code:
//t[][] Memory path, s[][] records the optimal path W (,,) as the weight functionConst intMAXN = -; voidMinweighttriangulation (intNintt[][ -],ints[][ -]){ for(intI=1; i<=n; i++) T[i][i] =0; for(intR=2; r<=n; r++) for(intI=1; i<=n-r+1; i++) { intj = i + R-1; T[I][J]= t[i+1][J] + W (i-1, I, J); S[I][J]=i; for(intK = i+1; k<j; k++) { intU = t[i][k] + t[k+1][J] + W (i-1, K, J); if(u<T[i][j]) {T[i][j]=u; S[I][J]=K; } } }}
If you have questions, see "Matrix multiplication" for your code.
Optimal triangulation of convex triangles