igraph

changing the color of a subgraph in igraph plot

一世执手 提交于 2019-12-04 17:09:03
I have the following code to plot the minimum spanning tree of a graph ## g is an igraph graph mst = minimum.spanning.tree(g) E(g)$color <- "SkyBlue2" ## how to I make mst a different color E(g)[E(mst)]$color = "red" ### <---- I WANT TO DO ESSENTIALLY THIS plot(g, edge.label=E(g)$weight) That is, for a simple graph, I find the mst. I want to change the mst to red and plot the mst as part of the main graph. To do this, I want to select the edges of g that are also in mst . How do I do this? UPDATE: More generally, I have a graph g0 which is the mst of g , which has n vertices. It was

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

若如初见. 提交于 2019-12-04 16:47:07
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)] <- "raster" #give every vertex the same image, regardless of shape V(g)$raster <- replicate(vcount(g),

Running R in the background

旧时模样 提交于 2019-12-04 13:53:07
Hi this is a question which i am not sure how to frame. I am running R from a remote server. My access to the remote server is via ssh@username and so on. After i access i have a command prompt which i invoke R and i am comfortable working on R. Question 1 I have a large network (100k nodes) and would like to do community detection and would like to run it in the background such that if i close my terminal its keeps running until its finished saves the result in my R working directory. I have tried using nohup R & but i am not sure the process completed successful. Question 2 If i manage to

Read a directed graph in R

放肆的年华 提交于 2019-12-04 13:04:22
问题 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

Installation of igraph package of R in ubuntu

那年仲夏 提交于 2019-12-04 10:15:13
I am using the following command for the installation of igraph package of R in ubuntu : install.packages("igraph") But I am getting an error saying: Warning: unable to access index for repository http://ftp.iitm.ac.in/cran/src/contrib : cannot open URL ' http://ftp.iitm.ac.in/cran/src/contrib/PACKAGES ' Warning messages: package ‘igraph’ is not available (for R version 3.3.2) Can someone please guide regarding this problem, where I am going wrong in this... You probably want a binary package anyway, and I recently re-explained how to do this: The easiest way is something like this (and I am

Vertex Labels in igraph with R

十年热恋 提交于 2019-12-04 09:43:52
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 (for example) from E to B are superimposed. (The same problem appears for vertex C-D and vertex B-F) I

(igraph) Grouped layout based on attribute

核能气质少年 提交于 2019-12-04 09:38:43
I'm using the iGraph package in R to layout a network graph, and I would like to group the vertex coordinates based on attribute values. Similar to the answered question How to make grouped layout in igraph? , my question differs in that the nodes needn't be grouped by a community membership that was derived from a community detection algorithm. Rather, I want to layout with groups based on attribute values that are known in advance for each vertex. For example, if each vertex has an attribute "Master.Org", and there are ~10 to ~20 distinct values for Master.Org, then how can I layout the

Using iGraph in python for community detection and writing community number for each node to CSV

蹲街弑〆低调 提交于 2019-12-04 09:17:43
问题 I have an network that I would like to analyze using the edge_betweenness community detection algorithm in iGraph. I'm familiar with NetworkX, but am trying to learning iGraph because of it's additional community detection methods over NetworkX. My ultimate goal is to run edge_betweenness community detection and find the optimal number of communities and write a CSV with community membership for each node in the graph. Below is my code as it currently stands. Any help figuring out community

Order of treechart entries not correct in R igraph package

こ雲淡風輕ζ 提交于 2019-12-04 06:44:08
问题 This is a follow-up question from : Creating treechart from tabbed text in R I am using following function: treechart = function(){ library(psych) fields <- max(count.fields(textConnection(readClipboard()), sep = "\t")) dat = read.table(text = readClipboard(), sep="\t",col.names = paste0("V", sequence(fields)), header=FALSE, fill=TRUE, strip.white=TRUE, stringsAsFactors=FALSE, na.strings="") library(zoo) library(igraph) # To prepare the data # carry forward the last value in columns if lower

R iGraph: How to get weighted adjacency matrix from a graph?

我们两清 提交于 2019-12-04 05:35:51
问题 While there are some questions dealing with creating a graph from an adjacency matrix, I haven't found much about extracting the weighted adjacency matrix from a weighted graph. Say I have the following graph: library(igraph) nodes <- data.frame(name=c("a","b", "c", "d", "f", "g")) col1 <- c("a", "g", "f","f", "d","c") col2 <- c("b", "f","c","d","a","a") weight <- c(1,4,2,6,2,3) edges <- cbind.data.frame(col1,col2,weight) g <- graph.data.frame(edges, directed=F, vertices=nodes) E(g)$weight <-