Subject: How to construct a tree from a given structure and elements

From: [email-masked] (Uwe Lesta)
Date: Mon, 04 Dec 2000 22:42:25 +0100

Please give me some advises on the following problem :

% The structure of a maximum possible tree is given by

% tree_struct(+child, +parent, +max_childs).
tree_struct(node1, root, 2).
tree_struct(node2a, node1, 5).
tree_struct(node2b, node1, 8).
tree_struct(node3a, node2a, 2).
tree_struct(node3b, node2a, 1).
tree_struct(node3a, node2b, 2).
tree_struct(node3c, node2b, 10).
% ...

% elements are given

% material(+node, +amount).
material(node3a, 7).
material(node3c, 30).
material(node2b, 6).

% Now I will add some rules to give each node some points
% and a maximum of points which are allowed for the childrens.

% node_points(+node, +green_points(+max_allowed, +amount), 
+red_points(+max_allowed, +amount)).
node_points(node1, green_points(200, 0), red_points(100,0)).
node_points(node2a, green_points(70, 1), red_points(30,2)).
node_points(node2b, green_points(70, 2), red_points(30,5)).
node_points(node3a, green_points(8, 4), red_points(2,1)).
node_points(node3b, green_points(8, 8), red_points(2,1)).
node_points(node3c, green_points(8, 1), red_points(2,0)).

What is the best way to write a program that build a balanced tree
from this facts ?

I am looking forward to read your advises

Thank you for your time 

-- 

Regards

Uwe
[email-masked]