开发者

Advantage and disadvantage of spanning tree with even distance

It's new year day and still can't solve my problem about a spanning tree algorithm. I can't insert picture yet so I have to try to explain the enviroment with words.

It's 36 nodes and the distance to every nodes is even. The question is if the distance is even, it doesn't matter which way to pass message from node with ID 1 (the root) to the last node with ID 36. Because the distance is even there's no time saving, energy saving or message saving algorithm right? I hope someone understand my question

edited:

  1. Enviroment

    1 - 2 - 3 - 4 - 5 - 6
    |   |   |   |   |   |
    7   8   9  10  11  12
    |   |   |   |   |   |
    13  14  15  16  17  18
    |   |   |   |   |   |
    19  20  21  22  23  24
    |   |   |   |   |   |
    25  26  27  28  29  30
    |   |   |   |   |   |
    31  32  33  34  35  36
    

This is my choice of spanning tree. Node with ID 36 send it information thru 30,24,18,12,6,5,4,3,2,1 (one is the root) and then node 1 send information to the base station. Because it doesn't have any cost it doesn't really matter which path I choose to send the information from node 36 to node 1 because the cost will still be the same.

  1. My Spanning tree Algorithm

    • When start, only the root is marked.
    • The root send search message to it neighbor
    • If a node is not marked, when it recieves search messages from other nodes:
    • it mark itself
    • Select the nodes with lowest ID as a "parent" and reply "non-parent" to the other nodes
    • If the node is already mark, it replies "non-parent"
    • If a node is already marked and recieve a parent message it marks the sender as a child
  2. I can't show you guys the flowchart because I don't have the privilege to insert image开发者_运维知识库s.

  3. Pseudo Code (haven't done it)

  4. Conclusion - Here I should write down the advantage and disadvantage of my algorithm, but right now I can't think of any advantage and disadvantage


By "even" I think you mean "Irregardless of where I start, the distance to move one node horizontally in my diagram is always 1, and the distance to move vertically is always 6."

Your question then sounds like "Do all paths from the upper left to the lower right have the same total length?" If we restrict our attention to paths that, at each step, always move either down or to the right, then the answer is "yes".

To see this, note we need in total to make 5 hops down, and 5 hops to the right. Suppose we pick a path that does so (but not necessarily in that order.) Since all downward hops have the same cost, and all rightward hops have the same cost, we can find the total cost of the path by considering each hop in order, writing a 6 for each downward hop and 1 for each rightward hop, and add the list together.

For example, the cost of path RRDDRDRDDR is 1 + 1 + 6 + 6 + 1 + 6 + 1 + 6 + 6 + 1.

Now we can see something interesting. A different path with 5 down hops and 5 right hops will have the same list of 5 6s and 5 1s, just summed in a different order. We can now observe that addition is commutative, and conclude that these two sums must come out equal. That is, any path moving down and to the right has the same total length (35) as any other.

Given that, your spanning tree is as good as any other, assuming the underlying graph really is a grid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜