-
Notifications
You must be signed in to change notification settings - Fork 7
Description
nw %n% "bipartite" and network.size(nw) - nw %n% "bipartite" are very common patterns, and having functions that extract them as a part of the API would make the client code more readable, without introducing a nontrivial maintenance burden.
One question is what these functions should do if nw is not bipartite. Here are the options as I see them:
- Error
- NULL or numeric(0)
- FALSE or 0
- network.size(nw)
- Wrap the above, i.e.,
b1.size(nw) == 0,b2.size(nw) == network.size(nw). - User-selected (i.e.,
unipartite = c("Error", "NULL", "FALSE", "all"), so picked because they have distinct first letters).
Option 1 will force the clients to program defensively and avoid unexpected behaviour. Option 2 will do so to a slightly lesser extent (i.e., if the code is such that it errs on NULL) but will enable the pattern along the lines of b1.size(nw) %||% network.size(nw) or, equivalently, NVL(b1.size(nw), network.size(nw)). Option 3 will also force some degree of defensiveness (if the code errs on 0) and will enable bipartedness and bipartition size to be queried in the same statement. Option 4 is the most likely to enable subtle bugs, but it also has the property that matrix(0, b1.size(nw), b2.size(nw)) will be the sociomatrix of nw regardless of whether or not it's bipartite. Option 5 has the property that b1.size(nw) + b2.size(nw) == network.size(nw).
@CarterButts , @mbojan , @sgoodreau , @martinamorris , @drh20drh20 , @handcock , thoughts?