-
Notifications
You must be signed in to change notification settings - Fork 78
Add depth method to tree class #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jeromekelleher Should I be using a |
Codecov Report
@@ Coverage Diff @@
## master #554 +/- ##
==========================================
+ Coverage 87.18% 87.20% +0.01%
==========================================
Files 21 21
Lines 16233 16251 +18
Branches 3184 3187 +3
==========================================
+ Hits 14153 14171 +18
Misses 1020 1020
Partials 1060 1060
Continue to review full report at Codecov.
|
jeromekelleher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Just a few very minor comments.
|
@petrelharp, do you agree with this definition of Tree.depth(u):
I think the PR is uncontroversial otherwise, no need to look over it. |
|
Actually, now that I look at it that definition is wrong! Maybe "Returns the number of nodes on the path from u to root, not including u. Thus, the depth of u is 0 if u is a root." |
|
Good catch! In the code I used the wording "above u" but I think it's better to just be more explicit and say not including u. |
"Above" is tricky, because a lot of people think of trees with the root at the bottom (I don't know where they got that from!), so it's good to avoid it if you can. Sometimes it just makes things unreadable if you don't choose a direction though. |
bdcafc6 to
9949bde
Compare
I agree with this, except that it should say "from u to a root". (probably what you meant to write). |
9949bde to
176218e
Compare
Now
t.depth(u)returns the depth of nodeuin treet, where depth is defined as the number of nodes on the path fromuto the root, not includingu.