igraph

R igraph: how to find the largest community?

天涯浪子 提交于 2021-02-07 19:51:46
问题 I use fastgreedy.community to generate a community object, which contains 15 communities. But how can I extract the largest community among these 15 communities? Community sizes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1862 1708 763 974 2321 1164 649 1046 2 2 2 2 2 2 15 2 In this example, I want to extract the community 5 for further use. Thanks! 回答1: Assuming that your community object is named community.object , which(membership(community.object) == x) extracts the indices of the vertices in

R igraph: how to find the largest community?

自作多情 提交于 2021-02-07 19:51:09
问题 I use fastgreedy.community to generate a community object, which contains 15 communities. But how can I extract the largest community among these 15 communities? Community sizes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1862 1708 763 974 2321 1164 649 1046 2 2 2 2 2 2 15 2 In this example, I want to extract the community 5 for further use. Thanks! 回答1: Assuming that your community object is named community.object , which(membership(community.object) == x) extracts the indices of the vertices in

igraph in R: converting a bipartite graph into a one-mode affiliation network

淺唱寂寞╮ 提交于 2021-02-07 19:18:40
问题 The following is a toy dataset I created using igraph in Rstudio for a bipartite network of terrorist perpetrators and their targets. The following specification is for a directed bipartite relationship between both types of vertices: set.seed(1234) df <- data.frame( perpetrator <- c( 'Armed Islamic Group (GIA)', 'Armed Islamic Group (GIA)', 'Algerian Islamic Extremists', 'Islamic Salvation Front (FIS)', 'Unindentified Activists', 'Armed Islamic Group (GIA)', 'Armata di Liberazione Naziunale

igraph in R: converting a bipartite graph into a one-mode affiliation network

雨燕双飞 提交于 2021-02-07 19:18:36
问题 The following is a toy dataset I created using igraph in Rstudio for a bipartite network of terrorist perpetrators and their targets. The following specification is for a directed bipartite relationship between both types of vertices: set.seed(1234) df <- data.frame( perpetrator <- c( 'Armed Islamic Group (GIA)', 'Armed Islamic Group (GIA)', 'Algerian Islamic Extremists', 'Islamic Salvation Front (FIS)', 'Unindentified Activists', 'Armed Islamic Group (GIA)', 'Armata di Liberazione Naziunale

igraph in R: converting a bipartite graph into a one-mode affiliation network

爱⌒轻易说出口 提交于 2021-02-07 19:18:30
问题 The following is a toy dataset I created using igraph in Rstudio for a bipartite network of terrorist perpetrators and their targets. The following specification is for a directed bipartite relationship between both types of vertices: set.seed(1234) df <- data.frame( perpetrator <- c( 'Armed Islamic Group (GIA)', 'Armed Islamic Group (GIA)', 'Algerian Islamic Extremists', 'Islamic Salvation Front (FIS)', 'Unindentified Activists', 'Armed Islamic Group (GIA)', 'Armata di Liberazione Naziunale

How can one set the size of an igraph plot?

。_饼干妹妹 提交于 2021-02-07 18:26:30
问题 I'm currently plotting my graphs like this: ig.plot(graph, target=file, vertex_color=membership, vertex_label=[index for index, value in enumerate(graph.vs)], vertex_frame_width=0, palette=ig.ClusterColoringPalette(len(set(membership)) + 3)) The plot is output to a PDF file on a single page. It looks decent but the nodes are too crowded. Is there a way to pull the nodes apart so that I can actually see all the edges? I was thinking of increasing the size of the plot but I don't know how to do

Python igraph: delete vertices from a graph

瘦欲@ 提交于 2021-02-07 12:12:27
问题 I am working with enron email dataset and I am trying to remove email addresses that don't have "@enron.com" (i.e. I would like to have enron emails only). When I tried to delete those addresses without @enron.com, some emails just got skipped for some reasons. A small graph is shown below where vertices are email address. This is gml format: Creator "igraph version 0.7 Sun Mar 29 20:15:45 2015" Version 1 graph [ directed 1 node [ id 0 label "csutter@enron.com" ] node [ id 1 label "steve

Minimum spaning tree with Kruskal' algorithm

こ雲淡風輕ζ 提交于 2021-02-07 09:07:38
问题 How i can calculate im R(3.0.0 - Linux x32) minimum spanning tree with Kruskal's algorithm? I create an weighted full graph with igraph (0.6.5) library as folws: set.seed(1234567890) g <- graph.full(n = 20) E(g)$weight <- round(runif(ecount(g)), 2) * 100 And i am able to calcutae the minimum spaning tree with Prim (igraph) mstPrim <- minimum.spanning.tree(g, algorithm = "prim") But unfortunaly doesn't in "igraph" Kruskal's algorithm implemented. I can represent my genereted graph as a data

Minimum spaning tree with Kruskal' algorithm

纵饮孤独 提交于 2021-02-07 09:04:18
问题 How i can calculate im R(3.0.0 - Linux x32) minimum spanning tree with Kruskal's algorithm? I create an weighted full graph with igraph (0.6.5) library as folws: set.seed(1234567890) g <- graph.full(n = 20) E(g)$weight <- round(runif(ecount(g)), 2) * 100 And i am able to calcutae the minimum spaning tree with Prim (igraph) mstPrim <- minimum.spanning.tree(g, algorithm = "prim") But unfortunaly doesn't in "igraph" Kruskal's algorithm implemented. I can represent my genereted graph as a data

How to select certain paths of a graph based on their length, using igraph in R

蹲街弑〆低调 提交于 2021-02-07 04:18:48
问题 given a graph, for example: require(igraph) g <- graph.famous("Zachary") such that some of its properties are: diameter(g) [1] 5 > farthest.nodes(g) [1] 15 17 5 > average.path.length(g) [1] 2.4082 > path.length.hist(g) $res [1] 78 265 137 73 8 $unconnected [1] 0 As you can see there are 8 paths with length = 5, 73 with length = 4, and so on... I would like to be able to isolate groups of nodes that are involved in a path of certain length. For example, I would like to know the nodes involve