igraph

How to restore attribute after union n igraphs?

你说的曾经没有我的故事 提交于 2019-12-06 04:52:28
let's say I have n igraphs objects g1 , g2 ,.., gn . They are undirected and weighted graphs, i.e. new weight's attribute should be added. I'd like to union n graphs into the weighted graph g . It is known from the documentation (see ?graph.union ) if the n graphs have the weight attribute, it is renamed by adding a _1 and _2 (and _3 , etc.) suffix, i.e. weight_1 , weight_2 ,..., weight_n . I have seen the answer and wrote the code for n=3 graphs (see below). Edited: library(igraph) rm(list=ls(all=TRUE)) # delete all objects g1 <- graph_from_literal(A1-B1-C1) g2 <- graph_from_literal(A2-B2-C2)

(igraph) Grouped layout based on attribute

南楼画角 提交于 2019-12-06 04:48:36
问题 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

Use shortest path to calculate probability of connection

旧巷老猫 提交于 2019-12-06 03:49:48
I'm wondering if there is a function within igraph to calculate connection probabilities among vertices in a weighted graph, where the weights for the edges are probabilities of connection of the adjacent vertices. I've built a graph based on such an adjacency matrix where adjacent connection probabilities form the weights (this is for a river network so each node of the graph is only connected to a single downstream node). I had hoped to use something like the shortest.paths function in igraph but that sums the weights rather than calculates the product of them and I can't work out a way to

Problems compiling C core of igraph with Python 2.7.9 Anaconda 2.2.0 on Mac osx 10.10.2

£可爱£侵袭症+ 提交于 2019-12-05 23:55:09
I wonder if anyone has had a similar issue to this and found a solution? I am trying to install igraph for with Python 2.7.9 Anaconda 2.2.0 on Mac osx 10.10.2. I managed to brew install homebrew/science/igraph OK but when I try to pip install python-igraph I get the following error: grep: /usr/lib/libiconv.la: No such file or directory sed: /usr/lib/libiconv.la: No such file or directory libtool: link: `/usr/lib/libiconv.la' is not a valid libtool archive make[3]: *** [libigraph.la] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Extracting

Modularity calculation for weighted graphs in igraph

坚强是说给别人听的谎言 提交于 2019-12-05 20:11:49
I used the fastgreedy algorithm in igraph for my community detection in a weighted, undirected graph. Afterwards I wanted to have a look at the modularity and I got different values for different methods and I am wondering why. I included a short example, which demonstrates my problem: library(igraph) d<-matrix(c(1, 0.2, 0.3, 0.9, 0.9, 0.2, 1, 0.6, 0.4, 0.5, 0.3, 0.6, 1, 0.1, 0.8, 0.9, 0.4, 0.1, 1, 0.5, 0.9, 0.5, 0.8, 0.5, 1), byrow=T, nrow=5) g<-graph.adjacency(d, weighted=T, mode="lower",diag=FALSE, add.colnames=NA) fc<-fastgreedy.community(g) fc$modularity[3] #[1] -0.05011095 modularity(g

Hamiltonian path using iGraph

隐身守侯 提交于 2019-12-05 20:02:51
I started evaluating igraph library and its functionality. I need to calculate hamiltonian path of a graph generated by igraph_de_bruijn() function. Is there any ready made function in igraph library for that? I don't want to implement it from scratch. An example in C would be perfect. The Hamiltonian path problem can be cast as a subgraph isomorphism problem, for which igraph has several functions. Construct a 1D lattice graph (a "line") with the same number of vertices as your graph, then search for this pattern using subisomorphism functions. Here's an example using the Mathematica

converting data frame into affiliation network in R

一个人想着一个人 提交于 2019-12-05 18:23:48
I have a data frame with the following format: name workplace a A b B c A d C e D .... I would like to convert this data frame into an affiliation network in R with the format A B C D ... a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 1 0 e 0 0 0 1 ... and I used the following program: for (i in 1:nrow(A1)) { a1[rownames(a1) == A1$name[i], colnames(a1) == A1$workplace[i]] <- 1 } where A1 is the data frame, and a1 is the affiliation network. However, since I have a large data frame, the above program runs very slow. Is there an efficient way that avoids looping in data conversion? Thank you very much! If

How to plan the most efficient route for patio lights

余生长醉 提交于 2019-12-05 18:20:17
I'm trying to string up some patio lights. Based on another question I asked, I realize I need an algorithm to solve a Route Inspection Problem to figure out the most efficient route the lights should take so there's minimal duplicate edges covered with lights. After some searching I realized that perhaps something like this would be my best bet: Solving Chinese Postman algorithm with eulerization . However, I'm having trouble creating the graph. Here's what it needs to look like: pink circles represent places in the structure I can hang lights from "Start" is the only available electrical

Delete weak correlations from network in igraph (vertices and edges)

送分小仙女□ 提交于 2019-12-05 18:19:35
I need to plot a network from a correlation matrix. A small subset of my data: Taxon CD1 CD2 Actinomycetaceae;g__Actinomyces 0.072998825 0.031399459 Coriobacteriaceae;g__Atopobium 0.040946468 0.002703265 Corynebacteriaceae;g__Corynebacterium 0.002517201 0.006446247 Micrococcaceae;g__Rothia 0.001174694 0.002703265 Porphyromonadaceae;g__Porphyromonas 0.023326061 0.114368892 Prevotellaceae;g__Prevotella 0.252894781 0.102308172 Flavobacteriaceae;g__Capnocytophaga 0.001174694 0.029320025 Aerococcaceae;g__Abiotrophia 0.002013761 0.003327095 Carnobacteriaceae;g__Granulicatella 0.042960228 0.049490539

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

老子叫甜甜 提交于 2019-12-05 18:01:46
问题 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? 回答1: I would use the edged