igraph

Coloring vertexes according to their centrality

放肆的年华 提交于 2019-12-05 02:19:09
问题 I am trying to change the color of the vertexes in an igraph generated graph. To be more specific, I have a 95 nodes graph created from an adjacency matrix and I would like to color them according to their degree/betweenness/eigenvalue centrality/closeness but I'm guessing that after I know how to do it with one, I'll be able to do it with others. So I've coded the basics of graph generation until now: dataset <- read.csv("~/Google Drive/Cours M2/Network Economics/Data/Collabs_2013.csv", sep=

How do I calculate weighted degree distributions with igraph in R?

拥有回忆 提交于 2019-12-05 02:08:43
Consider a dataframe df where the first two columns are node pairs and successive columns V1 , V2 , ..., Vn represent flows between the nodes (potentially 0, implying no edge for that column's network). I would like to conduct analysis on degree, community detection, and other network measures using the flows as weights. Then to analyze the graph with respect to the weights in V1 I do: # create graph and explore unweighted degrees with respect to V1 g <- graph.data.frame( df[df$V1!=0,] ) qplot(degree(g)) x <- 0:max(degree(g)) qplot(x,degree.distribution(g)) # set weights and explore weighted

changing the spacing between vertices in iGraph in R

放肆的年华 提交于 2019-12-05 01:44:19
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, 48, 15, 49, 15, 51, 15, 53, 15, 62, 15, 63) g <- graph( pairs ) plot( g,layout = layout.reingold.tilford

Placing vertex.label outside a circular layout in igraph

*爱你&永不变心* 提交于 2019-12-05 01:08:17
问题 I have a circular layout igraph. I want the vertex label to be displayed outside the circular region. Tried playing around the vertex.label.cex and vertex.label.degree but did not work. Please advice! 回答1: vertex.label.degree takes some serious (but straightforward) tweaking to do this. Here's an example from this gist. It's not my code (it's @kieran's, I believe), but it's a fully working example. ### Here's one way to do it. library(igraph) library(ggplot2) library(scales) ## The igraph

Change edge thickness in igraph plot R according to Edge Attributes

为君一笑 提交于 2019-12-04 23:42:50
I want to change the edge width of my graph to correspond to the edge.betweenness score. net <- read.csv("D:/SNA/R/Net.csv") att <- read.csv("D:/SNA/R/Att.csv") g <- graph.data.frame(net, vertices=att, directed=TRUE) pdf("Network.pdf", pointsize=8) plot(g, vertex.label=NA, vertex.size=3, edge.width=edge.betweenness(g)) dev.off() I have also tried creating the edge betweenness score as an edge weight and assigning it to edge.width argument in the plot function as follows; plot(g, vertex.label=NA, vertex.size=3, edge.width=E(g)$width Your example should work. Alternatively, you can write E(g)

How to install igraph for python on windows

蹲街弑〆低调 提交于 2019-12-04 22:15:00
问题 I have tried to install Igraph for python but of no avail I followed the procedure given on http://igraph.org/python/doc/tutorial/install.html I even tried Pycairo procedure given at the end of the site But igraph is not working either on Enthought Canopy or Anaconda Please help 回答1: Try using a precompiled binary here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-igraph Choose the proper version, use pip and type: python -m pip install path/to/igraph.whl Do not change the wheel name.

Building and adjacency matrix

丶灬走出姿态 提交于 2019-12-04 21:49:59
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 times that they are collaborating together. Does the following do what you are looking for? # simulate

Changing attribute values of nodes in a network during breadth first search in R

倾然丶 夕夏残阳落幕 提交于 2019-12-04 19:53:33
I have created a random (Erdos-Renyi) network that has 100 nodes. I have set an attribute value for all 100 nodes as 0. I find the node with the maximum degree (the most neighbors), and change its attribute value from 0 to 1. Then, using the node as the root node, I do a breadth first search (BFS) on the network. Here is my code to do this so far: # Loads the igraph package library(igraph) # Creates a random (Erdos-Renyi) network with 100 nodes and edges with p = 0.2 graph <- erdos.renyi.game(100, 0.2, type = c("gnp", "gnm"), directed = FALSE, loops = FALSE) # Sets the attributes of all the

assign multiple color to each vertex in igraph

女生的网名这么多〃 提交于 2019-12-04 17:38:51
I have a dataframe d : d<-structure(list(V1 = c(1L, 3L, 3L, 2L, 1L, 1L, 7L, 9L, 10L, 9L, 7L), V2 = c(2L, 4L, 5L, 5L, 4L, 6L, 8L, 3L, 1L, 8L, 5L)), .Names = c("V1", "V2"), class ="data.frame", row.names = c(NA, -11L)) g<-graph.data.frame(d,directed = F) I would assign to each vertex one or more colors depending on its affiliation variable given in a dataframe m m<-structure(list(vertex = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 9L, 9L, 10L, 1L, 1L, 6L, 6L), affilation = c(1L, 1L, 1L, 2L, 2L, 1L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L)), .Names = c("vertex", "affilation"), class = "data.frame", row

Interface between networkx and igraph

隐身守侯 提交于 2019-12-04 17:21:07
问题 I've been working with networkx for quite some time now and it's been serving my purposes quite well with minimal tweaks until recently when I started looking into community detection. In comparison, the igraph Python package seems to have a much wider implementations of community detection methods (even compared to networkx with Thomas Aynaud's community package added on). I'm just wondering if there's any existing, tested API that would allow easy translation of a networkx graph into the