igraph / rigraph

igraph R package
https://r.igraph.org
532 stars 200 forks source link

docs: fix `sample_degseq()` example #1297

Closed maelle closed 3 months ago

maelle commented 4 months ago

fix #1289

note that rlang::check_installed() will prompt the user to install withr, which is handy IMHO.

aviator-app[bot] commented 4 months ago

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes. Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.
szhorvat commented 4 months ago

How about just doing something like the following and avoiding withr?

while (! is_graphical(degs <- sample(1:100, 100, replace = TRUE, prob = (1:100)^-2)) ) {}

This keeps sampling until we hit on a graphical degree sequence (which happens with a high probability in this case).

I am not really in favour of the name vl_graph ... The Viger-Latapy method creates a simple and connected undirected graph, but we probably don't want to use a variable that spells all that out. I'd rather stick to g1, g2, g3, etc. and spell out their properties later.

No other comments except that I really hate the current method names and I am hoping that https://github.com/igraph/rigraph/issues/876 will be fixed soon ...