I apologise in advance as I am relatively new to igraph, and coding in general, and I hope my question is okay. But a bit of background - I have used igraph to create a graph with vertices and edges and then used the leiden algorithm to calculate my network.
My graph/network contains ~5800 vertices/nodes that are subsequently clustered into 2739 clusters, though the majority of these are singletons (~2000 - and I point out that I am not concerned by the number/think it is a true reflection of the data). For the purposes of clarity I would like to not plot these clusters i.e. if cluster <2 donāt show on final plot.
I believe to do this I want to create an induced subgraph and plot that? from here igraph R manual pages (please correct me if Iām wrong), but I am unsure how to reflect keeping only clusters above 2 in the vids argument (Numeric vector, the vertices of the original graph which will form the subgraph.). I am working in python for reference but am thinking to move to R for visualisingā¦
Using subgraph() may not be the most obvious solution for removing singletons from a graph.
That is directly removing the unwanted vertices. As in this example.
This has been incredibly helpful thank you so much for your time!
To ask a follow up - with your example to remove weakly connected components I get the below error (and same error when I add in my actual data). I was under the impression that wcc is a list? Am I missing something?
wcc ā components(g, mode=āweakā)
wcg ā groups(wcc)
Error in UseMethod(āgroupsā) :
no applicable method for āgroupsā applied to an object of class ālistā
Could I additionally ask one more question which is perhaps the reverse of my original question. Is it possible to select all the nodes and edges in a single cluster or set of of clusters (e.g. clusters 1:10) to subsequently graph as wellā¦
If this does not work on your system, perhaps the groups() function has been redefined. To avoid confusion you could try: igraph::groups(). This retrieves the function groups() from the igraph library.
If this does not remedy the problem then a separate question on this forum is worthwhile.
On my system groups() is defined as:
>groups
function (x)
UseMethod("groups")
<bytecode: 0x00000000176d83e0>
<environment: namespace:igraph>
>