I have a directed rooted tree with $n$ nodes.
Every node $n$ in the tree has a type $t_n$ and a cost $c_n$.
I also have a set of allowed node contractions in the tree.
I would like to find the minimal total cost of the tree when applying the node contractions.
costs: $$c_0=1$$ $$c_1=2$$ $$c_3=4$$ $$c_4=2$$ $$c_5=2$$ $$c_6=2$$ $$c_2=5$$
Contraction subsets on the form {nodetypes, newcost}->newtype: $\{3,4, 1\}\to7, \{5,6, 1\}\to8, \{5,2, 3\}\to9$
So a solution would be to contract 5 & 6 to a new node for lower cost. But it is also possible to contract 5 & 2 for a lower cost and contracting 3 & 4.
Is there any known algorithm or research I could use for this problem to find a minimal total cost for the tree?
This is intended to be used for simplifying algebraic expressions in a custom made algebra.
