igraph

changing the color of a subgraph in igraph plot

℡╲_俬逩灬. 提交于 2019-12-21 21:42:34
问题 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?

Installation of igraph package of R in ubuntu

房东的猫 提交于 2019-12-21 17:33:34
问题 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... 回答1: You probably want a binary

Built Family nested tree parent / children relationship in R

谁说胖子不能爱 提交于 2019-12-21 17:03:04
问题 I am working on families trees : I have adapted Bob Horton's example based on sqldf https://www.r-bloggers.com/exploring-recursive-ctes-with-sqldf/ My data : person father Guillou Arthur NA Cleach Marc NA Guillou Eric Guillou Arthur Guillou Jacques Guillou Arthur Cleach Franck Cleach Marc Cleach Leo Cleach Marc Cleach Herbet Cleach Leo Cleach Adele Cleach Herbet Guillou Jean Guillou Eric Guillou Alan Guillou Eric My results, descendants ordered by levels of "Guillou Arthur" (top person

igraph package in r: edge labels are overlapping

。_饼干妹妹 提交于 2019-12-21 09:33:01
问题 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)

representing a mosaic plot as a tree plot

China☆狼群 提交于 2019-12-21 05:35:12
问题 I want to visualize a mosaic plot in form of a tree. For example mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE) Now what I want is to represent this in a tree form where the first node for example be sex the second node be age and at the terminal node be number of people survived. May be it should something like http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=84 where instead of p giving the number of counts. Is there an function in R to do this or should I

Computing eigenvectors of a sparse matrix in R

我与影子孤独终老i 提交于 2019-12-21 05:21:15
问题 I am trying to compute the m first eigenvectors of a large sparse matrix in R. Using eigen() is not realistic because large means N > 10 6 here. So far I figured out that I should use ARPACK from the igraph package, which can deal with sparse matrices. However I can't get it to work on a very simple (3x3) matrix: library(Matrix) library(igraph) TestDiag <- Diagonal(3, 3:1) TestMatrix <- t(sparseMatrix(i = c(1, 1, 2, 2, 3), j = c(1, 2, 1, 2, 3), x = c(3/5, 4/5, -4/5, 3/5, 1)))

Community detection in Networkx

我怕爱的太早我们不能终老 提交于 2019-12-20 18:37:18
问题 I'm studying about detection communities in networks. I'm use igraph and Python For the optimal number of communities in terms of the modularity measure: from igraph import * karate = Nexus.get("karate") cl = karate.community_fastgreedy() cl.as_clustering().membership For supply the desired number of communities: from igraph import * karate = Nexus.get("karate") cl = karate.community_fastgreedy() k=2 cl.as_clustering(k).membership However, I like to do this using networkx. I know get optimal

igraph add to geographic map

女生的网名这么多〃 提交于 2019-12-20 15:23:10
问题 I'm using R for networks. I've used the 'network' package, but now using 'igraph'. I can plot the igraph using geographic coords. I can plot a map using 'maptools'(readShapePoly). How can I plot the igraph on top of the map? I have tried new=FALSE and add=TRUE but it doesn't work, plotting the igraph object always overwrites. greece <- readShapePoly.("Z:/GeoData/World_data/Basemaps/Greece/GRC_adm1.shp") df<-data.frame("from" = c.("Athens", "Iraklio", "Thessaloniki", "Patra"), "to"= c(

igraph creating a weighted adjacency matrix

偶尔善良 提交于 2019-12-20 10:28:11
问题 I'm trying to use the igraph package to draw a (sparse) weighted graph. I currently have an adjacency matrix, but cannot get the graph.adjacency function to recognise the edge weights. Consider the following random symmetric matrix: m <- read.table(row.names=1, header=TRUE, text= " A B C D E F A 0.00000000 0.0000000 0.0000000 0.0000000 0.05119703 1.3431599 B 0.00000000 0.0000000 -0.6088082 0.4016954 0.00000000 0.6132168 C 0.00000000 -0.6088082 0.0000000 0.0000000 -0.63295415 0.0000000 D 0

Display Edge Label only when Hovering Over it with Cursor - VisNetwork Igraph

淺唱寂寞╮ 提交于 2019-12-20 07:26:22
问题 Referring back to one of my previous post which contains the full reproducible code: VisNetwork from IGraph - Can't Implement Cluster Colors to Vertices My goal here is to change some of the visualization options from the visNetwork package graph. There are too many labels currently when I zoom in and it is very tough to distinguish which node belongs to which label. Is it possible to remove the labels from the visNetwork graph, and only display the labels when I hover over a node? I have