-
-
Notifications
You must be signed in to change notification settings - Fork 201
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
Add a convenience function to return the largest connected component of a graph #785
Comments
This request makes a lot of sense. Both the Python and Mathematica interfaces of igraph have such a function, as this is indeed a very common task. Since this is relatively simple to implement, would you like to open a pull request? I would suggest including a |
Sure, I will give it a shot. Thanks! |
Sorry to bug you with trivial things, but I'm having some trouble going the steps outlined in CONTRIBUTING.md. I have adjusted the function to include the mode argument and the roxygen2-style documentation. However, I don't seem to be able to run Details Here's the function, which I put in my forked version of
I ran
The documentation in
I have gcc-12.2.1-2 installed. |
Thanks. The following steps should work:
Can you confirm? |
That did the trick: I ran
Now with a fresh R session I can use my function, but I can't load the man page. I've never used roxygen2 before, so maybe I did something wrong there? Here's the session:
|
You need Would you like to improve |
There it is! Worked. Sure, I can give it a try. Shall I send this pull request, then do a separate issue and pull request for |
Yes, please. Focused pull requests are best. We review and merge when good (or good enough). We're experimenting with optimistic merging, and are also happy to provide feedback if it helps you. |
Does that make sense? |
Ha! Nope! But I'll figure it out. I think I skipped the branch part earlier, because locally git says I'm working on |
Never mind: reading the blog post and clicking around on GitHub I think I'm tracking now. Let me try to submit this PR on my own branch like you say and then move on to the |
Take your time, thanks for pushing through! |
Definitely! I use igraph pretty much every day, so hopefully this helps, even if only a little. I definitely appreciate all the time you all put into igraph. |
Ok, I think I've submitted the pull request. I made it a draft pull request to hopefully minimize any trouble if I've done something wrong. The branch should be called |
Thanks so much! Your feedback as a first-time contributor is extremely valuable. Regarding pull requests, maybe https://usethis.r-lib.org/articles/pr-functions.html can be useful if you use usethis (and if you don't use usethis, maybe it can suit your workflow preferences). |
Thanks! I will check it out. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary. |
What is the feature or improvement you would like to see?
A function that takes a graph with possibly many components and returns an induced subgraph that is the largest connected component of the original graph.
Use cases for the feature
I routinely need to extract the largest connected component of a graph (or largest weakly connected component of a directed graph) for further analysis. This use case comes up both in sampling graphs from an ensemble (e.g., when the sampling algorithm has generated isolated nodes that I want to ignore) and in working with empirical networks (e.g., when a data set contains information on microscopic clusters of nodes that are not critical for understanding the primary network). I have a function written that does this (modified from a StackOverflow post, link and function below), but an official version in igraph would be better if there's a general interest.
References
I wrote the below function modified from this StackOverflow post. It seems to work well enough, but it probably isn't as complete as it could be. I'd be happy try to improve it if there are some things it needs to be up to standard.
The text was updated successfully, but these errors were encountered: