Center of Tree - Onion peeling technique

Technique mentioned in attached link, we calculate the degree of each node, Is there reason why we cannot just select the node with highest degree as the center? I think I'm missing something here. With assumption that I'm storing degree of each node say in a map along with reference to node.

https://github.com/williamfiset/Algorithms/blob/master/src/main/java/com/williamfiset/algorithms/graphtheory/treealgorithms/TreeCenter.java

Line 22-30 - degree of all the nodes are being stored in the array (degree[])

Comments (1)