Skip to content

Add b1.size() and b2.size() alongside network.size(). #94

@krivit

Description

@krivit

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:

  1. Error
  2. NULL or numeric(0)
  3. FALSE or 0
  4. network.size(nw)
  5. Wrap the above, i.e., b1.size(nw) == 0, b2.size(nw) == network.size(nw).
  6. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions