예제 #1
0
import Tree

print("Loading the tree")
test_tree = {1: [2, 3], 2: [4, 5], 3: [6, 7, 8, 9], 4: [], 5: [], 6: [], 7: [], 8: [], 9: []}


node_weights = {1: 100, 2: 50, 3: 80, 4: 20, 5: 50, 6: 30, 7: 50, 8: 100, 9: 200}

Tree.aggregate(test_tree, node_weights, 6, keep_intermediate=True)
# aggregated_trees = Tree.agg_to(test_tree, node_weights, 6, keep_intermediate=True)


# print "Done"
#
# print "Reducing the tree to 6 nodes"
#
# reduced_trees = Tree.agg_to(test_tree, 6)
#
# print "Done"
#
# print "Checking if lower left example tree from figure 2 in paper is in the permutations"
#
# check_tree = {
#    1: [(2, (4, 5)), 3],
#    (2, (4, 5)): [],
#    3: [(6, 7), 8, 9],
#    (6, 7): [],
#    8: [],
#    9: []
#    }
#
예제 #2
0
    7: [],
    8: [11, 12, 13, 14, 15],
    9: [],
    10: [],
    11: [],
    12: [],
    13: [],
    14: [],
    15: [],
}

artificial_tree_weights = {
    1: 100,
    2: 20,
    3: 80,
    4: 80,
    5: 320,
    6: 30,
    7: 20,
    8: 40,
    9: 400,
    10: 50,
    11: 30,
    12: 80,
    13: 180,
    14: 20,
    15: 75,
}

Tree.aggregate(artificial_tree, artificial_tree_weights, 4, keep_intermediate=True)