I am going through available posts on this.
So diameter of graph:- Length of the longest distance between any two nodes.By distance it mean number of edges.
And diameter of tree :- the number of nodes on the longest path between any two leaf nodes
My question is as tree is a graph,so why can't we use same definition as of diameter of graph in tree.Are these totally different concepts?
Best Answer
You can use the same definition for trees. The two definitions you gave agree in the case of trees, since the longest path between two nodes will always be between two leaves (otherwise, you could extend the ends until you hit a leaf).
It's true that you link to a definition of tree diameter which counts nodes in the longest path, rather than edges. I think this is just an instance of the usual definition churn--different people have different ideas about what length means, and you always have to make sure you're on the same page.