Hi, I have an unordered tree. Each node represents a task that can be done (1), not done (0) or have children tasks.
For example:
1
-1.1
-1.2
--1.2.1
--1.2.2
-1.3
2
3
-3.1
4
-4.1
--4.1.1
5
Suppose that the leaves 1.2.1, 3.1 and 5 are done
1
-1.1
-1.2
--1.2.1*
--1.2.2
-1.3
2
3
-3.1*
4
-4.1
--4.1.1
5*
I want to calculate the percentage of completeness of each node. The leaves are easily calculated with 0% or 100%, but how to compute all the others?
At the moment, I walk the tree from the leaves on and each node is calculated based on the percentage of completeness of the children. For example:
1 50%
-1.1* 100%
-1.2 0%
2 0%
3 33%
-3.1* 100%
-3.2 0%
-3.3 0%
Now, more children are added to 1.2 (that is no more a leaf but becomes a node). If the children are "not done", 1.2 is always 0% and so 1 is 50%, but I would like 1 to be less then 50%, as, descending into his children and grand-children the number of tasks to be completed in order for it to the done 100% is greater!
1 50%
-1.1* 100%
-1.2 0%
--1.2.1 0%
--1.2.2 0%
2 0%
3 33%
-3.1* 100%
-3.2 0%
-3.3 0%
What is the best way to calculate this? Thanks