Repository navigation
DOC: rework betweenness centrality docstrings - #8264
Conversation
dschult
left a comment
There was a problem hiding this comment.
Looks good... some suggestions below...
And a nit: looking at the docs, and at the doc_strings (which I like to keep readable too), I'd be in favor of removing the \text{} around the subscript B. I think it makes the html docs very slightly worse (the B touches the c it subscripts). But it makes the raw latex code in the doc_string much less readable.
Similarly, I'd prefer to use | instead of \mid. The whitespace in the rendered docs is slightly annoying, but more importantly the TeX command \mid really has no obvious connection with the vertical bar symbol. IMO | looks better in both the rendered html and in the ascii doc_strings. But these are very minor. Do what you prefer.
Co-authored-by: Dan Schult <[email protected]>
|
@dschult I've updated the docstring for |
… of undirected graphs
dschult
left a comment
There was a problem hiding this comment.
Thanks! This is nice. I'm still finding it fills my brain to think about endpoints and normalization together and sometimes I get confused whether the discussion is about the example or is a general result. So I have some suggestions that try to separate those. See what you think... I'm not saying this language is needed... just some way to separate the (many) ideas a little. :)
…ring Co-authored-by: Dan Schult <[email protected]>
|
Thanks for the discussion, Dan! I really like your suggestion to separate discussing endpoints and normalization. I've updated the text a bit to hopefully make that distinction more clear. I believe I've also addressed your other comments. I'll push this up one more time for a final check before making changes to other functions. |
|
Actually, we should include a discussion of setting an explicit |
dschult
left a comment
There was a problem hiding this comment.
I have a couple of minor rewording suggestions. Nothing to stop continuation to other doc_strings.
And I see your point that we should probably include an example where k is prescribed. Perhaps after the current example, we could use the same graph, but choose k=2 and suppose that the two nodes chosen are {0, 2}. (or make then {0, 1} if that makes things clearer.
Co-authored-by: Dan Schult <[email protected]>
|
Thanks for the suggestions Dan! They improve the flow of the docstring. I'm purposely leaving out the case when setting I'll work on the remaining docstrings tomorrow when I have some time. |
|
I'm going to mark this as ready for review since I want to propose some changes to the subset centralities that would require changing the docs anyways:
The motivation for those changes is being able to make full BC a wrapper around subset BC. Another thing I noticed that I'm mentioning in passing: the default value of |
rossbar
left a comment
There was a problem hiding this comment.
Generally LGTM, thanks @Peiffap ! The examples are quite detailed, but then again there is a lot to consider with BC, especially with the combinations of parameters (k, endpoints) and graph properties (directedness) that all dictate semantics. I think the proposed example does a good job of capturing the important bits! I went through and compared the examples with the implementation, and AFAICT the explanations are all aligned.
I left a few minor suggestions re: wording and/or example ordering but none of these are blockers. Note also that I only left the explicit comments in the first functionn, so if you decide to go with them, it'd be good to apply the changes to the other modified docstrings too.
Co-authored-by: Ross Barnowski <[email protected]>
|
I believe 8c05d37 addresses your comments; I had to rewrite things slightly to take the final comment into account, but I believe the average distance from explanation to example is now shorter :) |
| Otherwise holds the name of the edge attribute used as weight. | ||
| Weights are used to calculate weighted shortest paths, so they are | ||
| interpreted as distances. | ||
| If `None`, all edge weights are considered equal. |
There was a problem hiding this comment.
| If `None`, all edge weights are considered equal. | |
| If `None`, all edge weights are considered equal and treated as 1. |
There was a problem hiding this comment.
It doesn't matter what the weights are as long as they're all the same, right? I'd slightly prefer to keep it generic if so; personally ("describe the behavior, not the implementation"). Let me know if you have a strong preference!
There was a problem hiding this comment.
hmm... Why not describe both the behavior and the implementation if its easy to do so?
We use this idiom of weight is None to mean all edge weights are 1 in many places, and we describe the edge weight as defaulting to 1 in many places (probably all the same places -- but maybe not?? -- do we ever have weight is None mean all edge weights are 1 while also allowing the user to pick a default edge weight?) The answer is not relevant really. The point is that we describe this situation in many places and this change is quite different from the other descriptions. That's why I suggested this change.
Also, is the fact that they are treated as equal the main idea of unweighted treatments? The equality is a side-effect -- not the main effect IMO. I mean, unweighted shortest paths count the number of "hops" across edges in the network. Counting is the same as summing 1s. I've never seen this described as treating all edges as equal. The text just talks about counting instead of summing -- or it talks about edge weights being 1. Indeed, if we set the weights to be all equal to 10, we would not find the length to be the number of hops across edges.
(we're in the weeds here, and that's fine -- I like weeds as well as nits) I guess I'm pushing pack on the notion that equal edge weights is the behavior. In fact the behavior is counting edges along the path (or hops across edges) and that is equivalent to considering edge weights as 1.
My preferred language would be: ... all edge weights are 1. But my suggestion includes both perspectives.
There was a problem hiding this comment.
Thanks for the additional context. My issue is with having both; to me that obfuscates things. I've amended the PR to have your "preferred language" instead; I'm happy with this too. :) (Additionally, "considered equal" doesn't work for some pathological weights anyways so this is actually a meaningful nit.)
| in each direction, as the shortest paths can differ by direction. | ||
| However, in undirected graphs, each pair of nodes is considered only once, | ||
| as the shortest paths are symmetric. | ||
| This means the normalization factor to divide by is $N(N-1)$ for directed graphs |
There was a problem hiding this comment.
The normalization factor appears in the formula as sigma right? And the formula is the normalized BC value. Maybe we should add that somewhere near the formula. Something like:
The denominator $\sigma(s, t)$ is a normalization factor that can be turned off to get the
raw path counts.
Should we also use \sigma in these expressions? Not sure...
There was a problem hiding this comment.
That's also my interpretation of the formula, and it would track with normalized defaulting to True. I've added the suggested blurb where appropriate.
Note that for the subset betweenness centralities, the parameter defaults to False... But it still has the normalization as part of the formula. Nothing major, but that's an annoying inconsistency that we might want to change at some point...
I think we shouldn't use \sigma outside of the formula.
Co-authored-by: Dan Schult <[email protected]>
|
Thanks for the suggestions, @dschult! I think they help clarify some of the stuff re: normalization for approximated centrality, which is probably the hardest part to grok of it all. |
Co-authored-by: Dan Schult <[email protected]>
Fix #8263.
This PR addresses some of the points in the linked issue. Currently, I've only included an example for
betweenness_centrality. If that one seems reasonable enough, I'll adapt it for the other 3 functions.