1
$\begingroup$

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?

$\endgroup$
4
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks. I was also thinking the same. $\endgroup$ – rahul sharma Jun 22 '17 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.