【问题标题】:Select head node after minimum-weight spanning tree algorithm最小权重生成树算法后选择头节点
【发布时间】:2012-02-27 22:16:13
【问题描述】:

我已经实现了Prim's algorithm 来找到我的图表的最小权重生成树,它工作正常。

现在我想在生成树中选择“最佳”头部。 “最好”是指更平衡的头部,例如,我是否应该在 treeView UI 中显示树。我敢肯定有很多算法可以解决这个问题,但我不知道如何命名问题!

【问题讨论】:

    标签: algorithm graph-algorithm


    【解决方案1】:

    您可以使用的一个标准是从节点到所有其他节点的平均距离。选择平均距离最小的节点。您也可以尝试平均平方距离等。

    【讨论】:

      【解决方案2】:

      嗯,有 splay treesAVL Trees 可以满足您的要求,但每个节点最多只能有 2 个子节点。 你可以尝试修改它们。问题可能是Form a tree which is as wide as possible

      【讨论】:

        【解决方案3】:

        您可以使用“最内层”节点,最大化到叶子的最小距离。要计算它,我认为以下算法可能有效(我没有验证它):

        S = set of all leaves of the tree
        foreach node in S: mark(node)
        repeat:
          # at each iteration, S is the set of all nodes at
          # a given min distance to a leave
          # initially this distance is 0, then 1, etc.
          S' = empty set
          foreach node in S:
            parent = parent(node)
            if !marked(parent): S' += parent; mark(parent)
          if S' is empty then S contains all innermost nodes, we are done
          S = S' and continue
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-01-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-05-11
          相关资源
          最近更新 更多