igraph

How to colour edges within community clusters in igraph

旧巷老猫 提交于 2019-12-06 22:49:39
I have created a graph and used the propagating labels community detection algorithm to detect subgroups in the graph. I have then plotted the graph and coloured the vertices according to their group membership using rainbow colours. Here is the code I used: g <- watts.strogatz.game(1, 100, 5, 0.05) clp <- cluster_label_prop(g) V(g)$community <- clp$membership rain <- rainbow(14, alpha=.5) V(g)$color <- rain[V(g)$community] plot(g, vertex.size=4, vertex.label=NA) I would now like to colour edges that lie between members of a subgroup in the same colour as that subgroup, in order to better

changing the spacing between vertices in iGraph in R

你说的曾经没有我的故事 提交于 2019-12-06 22:07:26
问题 Suppose I want to make a plot with the following data: pairs <- c(1, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 2, 11, 4, 14, 4, 15, 6, 13, 6, 19, 6, 28, 6, 36, 7, 16, 7, 23, 7, 26, 7, 33, 7, 39, 7, 43, 8, 35, 8, 40, 9, 21, 9, 22, 9, 25, 9, 27, 9, 33, 9, 38, 10, 12, 10, 18, 10, 20, 10, 32, 10, 34, 10, 37, 10, 44, 10, 45, 10, 46, 11, 17, 11, 24, 11, 29, 11, 30, 11, 31, 11, 33, 11, 41, 11, 42, 11, 47, 14, 50, 14, 52, 14, 54, 14, 55, 14, 56, 14, 57, 14, 58, 14, 59, 14, 60, 14, 61, 15,

Building and adjacency matrix

落爺英雄遲暮 提交于 2019-12-06 16:54:05
问题 I was wondering if you guys can help me building an adjacency matrix. I have data in CVS format like this: Paper_ID Author 2 Foster-McGregor, N. 3 Van Houte, M. 4 van de Meerendonk, A. 5 Farla, K. 6 van Houte, M. 6 Siegel, M. 8 Farla, K. 11 Farla, K. 11 Verspagen, B. As you can see the column "Paper_ID" has a repeated value of 11, meaning that "Farla, K." and "Verspagen, B." are coauthors of a publication. I need to build a square weighted matrix using the names of the authors, counting the

UnicodeDecodeError when installing python-igraph

三世轮回 提交于 2019-12-06 15:29:20
I'm using python 2.7 on 64-bit Linux Mint 16 and I'm trying to install python-igraph. But when I run sudo pip install python-igraph I get the following log: Downloading/unpacking python-igraph Downloading python-igraph-0.7.1-1.tar.gz (375kB): 375kB downloaded Running setup.py egg_info for package python-igraph Installing collected packages: python-igraph Running setup.py install for python-igraph Build type: dynamic extension Include path: /usr/include/igraph Library path: Linked dynamic libraries: igraph Linked static libraries: Extra compiler options: Extra linker options: building 'igraph.

Finding Strong and Weak Clusters and their membership in R

谁都会走 提交于 2019-12-06 11:53:07
问题 I should find weak clusters and membership of the nodes in the clusters, and strong clusters and membership of the nodes in the clusters. My code : library(igraph) g <- erdos.renyi.game(8, 15/100) is.connected(g, mode=("strong")) clusters(g, mode="strong") no.clusters(g, mode="strong") cluster.distribution(g, cumulative = FALSE, mul.size = FALSE) As solution I got this : > library(igraph) > g <- erdos.renyi.game(8, 15/100) > is.connected(g, mode=("strong")) [1] FALSE > clusters(g, mode=

Change attributes of one node

扶醉桌前 提交于 2019-12-06 11:23:39
How to change a color label node from its id or name? Ex: I want to change label color node name="4" or id=3 g9<- graph(c(0,1,0,2,0,3,1,4,1,2,3,4,3,5,4,5,5,2),n=6,dir=FALSE) V(g9)$name<-c(1:6) V(g9)$label<-V(g9)$name V(g9)$color is an array of colors. To change color of a specific node say 2: V(g9)$color[2] ="#343434FF" If you want different color for each node, you can specify rainbow(n) where n is number of nodes and this function generates a array of colors and then you can specify: V(g9)$color=rainbow(9) Also note: To get a list of vertices or nodes you can get them: V(g9) and then if you

Install python-igraph with the anaconda distribution (windows)

会有一股神秘感。 提交于 2019-12-06 11:04:32
I have problems to install python-igraph on the anaconda distribution of python. If I write pip install python-igraph (with the admin privileges) in the anaconda command, the installation doesn't work. Check the documentation on their site: http://igraph.org/python/ It says that you need to download the .msi installer, pip does not work under windows. That is probably because you need a C compiler and windows does not supply one by default. Jan Katins You can download a wheel installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-igraph and then install that wheel in your environment

R igraph, how to plot vertices with mix of shapes and raster?

谁都会走 提交于 2019-12-06 08:44:33
问题 I'm trying to plot a graph with R and igraph, using a mix of shapes and raster images for the vertices. I've modified the igraph example below to reproduce my problem. Can someone see what is wrong? You'll need a png file to test the script. library(png) library(igraph) img.1 <- readPNG(system.file("img", "Rlogo.png", package="png")) shapes <- setdiff(shapes(), "") g <- make_ring(length(shapes)) V(g)$shape <- shapes #change the rectangle variants to raster V(g)$shape[grepl("rect",V(g)$shape)]

Convert python-igraph graph to networkx

拥有回忆 提交于 2019-12-06 07:10:47
问题 Recently I've been working with python-igraph package and all my code is based on graphs I create using igraph. Right now, I need to calculate some measures for my graph which apparently are implemented in networkx and not in igraph such as (katz_centrality_numpy, edge_betweenness_centrality, ...). I am wondering if there is a way to convert one graph to another between these two packages and to avoid reading from files again since my files are huge and have to repeat the same process alot.

Vertex Labels in igraph with R

北城余情 提交于 2019-12-06 05:54:43
问题 I have some issue while adding vertex labels in a weighted igraph working with R. The data frame of the graph is: df <- read.table(text= "From, To, Weight A,B,1 B,C,2 B,F,3 C,D,5 B,F,4 C,D,6 D,E,7 E,B,8 E,B,9 E,C,10 E,F,11", sep=',',header=TRUE) # From To Weight # 1 A B 1 # 2 B C 2 # 3 B F 3 # 4 C D 5 # 5 B F 4 # 6 C D 6 # 7 D E 7 # 8 E B 8 # 9 E B 9 # 10 E C 10 # 11 E F 11 and I use : g<-graph.data.frame(df,directed = TRUE) plot(g) to plot the following graph : One can see that vertex labels