igraph

igraph package in r: edge labels are overlapping

岁酱吖の 提交于 2019-12-04 03:17:10
I am working with the igraph package in R to visualise network flows. library(igraph) # Example Data: b <- c("countryA", "countryB", "countryC", "countryA", "countryC", "countryA") c <- c("countryB", "countryC", "countryA", "countryB", "countryA", "countryB") d<- c(100, 200, 200, 300, 400, 200) e <- c(5,12,10,24,25,12) mydata <- data.frame(b,c,d,e) colnames(mydata) <- c("exporteur", "partner", "tradeflow", "price") # Plot in igraph mydata.igraph <- graph.data.frame(mydata) E(mydata.igraph)$label <- mydata[,3] plot(mydata.igraph) As you can see, my edge labels (labels of the arrows) are

Using igraph, how to force curvature when arrows point in opposite directions

烂漫一生 提交于 2019-12-04 02:27:14
autocurve.edges does an amazing job of curving edges in igraph plots so that they don't overlap when they point in the same direction. However, when they point in opposite directions, no curvature is applied. d <- data.frame(start=c("a","a","b","c"),end=c("b","b","c","b")) graph <- graph.data.frame(d, directed=T) plot(graph, vertex.color="white") The issue is for the arrows between b and c (or c and b). Other than specifying curvature manually, any suggestions? I would use the edged.curved option with the same seq call that autocurve.edges uses. plot(graph, vertex.color="white", edge.curved

Loading neo4j query result into python's `igraph` graph

非 Y 不嫁゛ 提交于 2019-12-04 02:04:07
问题 How would you load the results of a Cypher query into an igraph in python, keeping all the edge and vertex attributes? 回答1: This is easy with py2neo and igraph's Graph.TupleList method. You'll need both py2neo and igraph installed. pip install py2neo pip install python-igraph Both of these packages rely on a Graph class so we should alias them as something else on import. from py2neo import Graph as pGraph from igraph import Graph as iGraph First, connect to Neo4j with py2neo's Graph object.

plotting communities in iGraph

我们两清 提交于 2019-12-03 21:54:00
I would like to reproduce the kind of "community summary" graph like on page 6 of this paper: http://arxiv.org/pdf/0803.0476v2.pdf First a community algorithm is employed on the graph, e.g.: wc <- walktrap.community(subgraph) mc <- multilevel.community(subgraph) Then the vertices are grouped according to community. The size of the community node is a function of the membership size and the edge width is a function of the total edges going from any member of community A to community B. Please note I don't just want to encode community as color or convex hulls like this: V(inSubGraph)$color <-

R iGraph Heatmap in Vertex

半腔热情 提交于 2019-12-03 16:24:55
I'm quite new to R and stuck on a question. Would it be possible to print a heatmap on a vertex in iGraph ? I know I can do a colored square or circle. But would a small heatmap be possible? This is the code that draws my current graph: # create graph graph <- graph.data.frame(network[,1:2]) vertex_names <- get.vertex.attribute(graph,"name") # define node attributes V(graph)$label.font <- 1 V(graph)$label.font[which(element_types[vertex_names,"type"]=="PRIMARIES")] <- 2 V(graph)$label.font[which(element_types[vertex_names,"type"]=="REACTION")] <- 2 V(graph)$label <- element_types[vertex_names,

Coloring vertexes according to their centrality

随声附和 提交于 2019-12-03 16:16:57
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=";") matrix<-as.matrix(dataset) adj<-graph.adjacency(matrix) plot(adj) btw<-betweenness(adj,directed =

How to mine for motifs in R with iGraph

三世轮回 提交于 2019-12-03 13:07:55
问题 I'm trying to mine for 3-node motifs in R using the package igraph . I would like to retrieve the number of motifs for each individual vertex in the graph, which does not appear possible from the graph.motifs() function. So, for the example graph: testGraph = barabasi.game(10, m = 5, power = 2, out.pref = TRUE, zero.appeal = 0.5, directed = TRUE) I can use graph.motifs() to count the total number of each 3-node motif in the entire graph: graph.motifs(testGraph, size = 3) [1] 0 0 26 0 16 0 2

Interface between networkx and igraph

。_饼干妹妹 提交于 2019-12-03 11:18:58
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 igraph structure, so I can avail myself of the power igraph provides in this area? Your kind answers are

Differences in centrality measures between igraph and tnet

徘徊边缘 提交于 2019-12-03 09:59:07
问题 I'm trying to obtain centrality measures for a directed, weighted network. I've been using the igraph and tnet packages in R . However, I've discovered some differences in the results obtained using these two packages, and I'm a little confused about the cause of these differences. See below. require(igraph) require(tnet) set.seed(1234) m <- expand.grid(from = 1:4, to = 1:4) m <- m[m$from != m$to, ] m$weight <- sample(1:7, 12, replace = T) igraph_g <- graph.data.frame(m) tnet_g <- as.tnet(m)

Read a directed graph in R

心已入冬 提交于 2019-12-03 08:18:36
I have trouble reading/creating a directed graph. I followed the steps I have found here . This is my text file graph.txt : 1 2 1 3 2 5 3 4 3 5 4 5 5 6 5 10 6 7 7 8 7 9 7 12 8 9 9 10 9 11 9 12 10 11 11 7 11 12 Now I read this graph.txt : library("igraph") xlist<-read.graph("graph.txt", format="edgelist") And then I plot it: plot(xlist) But it is not the graph I have read into xlist: As you can see there is no edge between 1->2, 1->3, 5->10 and so on. How can I read the directed graph correctly? Having done this, how can I show all shortest paths between two nodes? user1317221_G This seems to