igraph

Shortest path from osmar object to igraph in R. Trying to replicate an osmar documentation example

核能气质少年 提交于 2020-07-10 07:47:51
问题 i am trying to get started with openstreetmap in R and try to replicate the example given in osmar package documentation. I get a bit data for munich. src <- osmsource_api(url = "https://api.openstreetmap.org/api/0.6/") muc_bbox <- center_bbox(11.575278, 48.137222, 1000, 1000) muc <- get_osm(muc_bbox, src) I get a subset of all highways in munich hways_muc <- subset(muc, way_ids = find(muc, way(tags(k == "highway")))) hways <- find(hways_muc, way(tags(k == "name"))) hways <- find_down(muc,

Synchronise colors between plot and legend

允我心安 提交于 2020-06-28 07:01:56
问题 I have this command to produce a network graph from igraph: plot(ig, layout=layout.fruchterman.reingold(ig),vertex.label=NA,vertex.label.color="black",vertex.frame.color="black",edge.color="black", vertex.color=rainbow(9)[data2$Group], main="MB Network") The data2 is another object containing information on groupings of the vertices in the igraph object ig. I wanted to color the vertices by their groupings and then put a legend for group color guidelines so I used the command: legend("topleft

Retrieving binary interactions from linkcomm package as a data frame in R

﹥>﹥吖頭↗ 提交于 2020-06-17 00:06:30
问题 Suppose I have the following clusters: library(linkcomm) g <- swiss[,3:4] lc <-getLinkCommunities(g) plot(lc, type = "members") getNodesIn(lc, clusterids = c(3, 7, 8)) From the plot you can see the node 6 is present in 3 overlapping clusters: 3, 7 and 8. I am interested to know how to retrieve the direct binary interactions in these clusters as a data frame. Specifically, I would like a data frame with the cluster id as the first column, and the last two columns as "interactor 1" and

IGRAPH IN R: Find the path between vertices that maximizes the product of edge attributes

蹲街弑〆低调 提交于 2020-06-16 05:33:32
问题 I need to find a way to find the path between two vertices that maximizes the product of edge attributes. In my case the edge attribute is a probability of connection. Let's assume I want to find the maximum probability path between the vertex 1 and 4 in the following example: require(igraph) G<-graph.data.frame(as.data.frame(cbind(id1=c(1,1,2,3,1,4),id2=c(2,3,4,4,5,5),weight=c(0.5,0.35,0.5,0.9,0.6,0.6))), directed=FALSE) plot(G, edge.label=paste(E(G),"=",signif(E(G)$weight, digits=1)),

IGRAPH IN R: Find the path between vertices that maximizes the product of edge attributes

眉间皱痕 提交于 2020-06-16 05:32:32
问题 I need to find a way to find the path between two vertices that maximizes the product of edge attributes. In my case the edge attribute is a probability of connection. Let's assume I want to find the maximum probability path between the vertex 1 and 4 in the following example: require(igraph) G<-graph.data.frame(as.data.frame(cbind(id1=c(1,1,2,3,1,4),id2=c(2,3,4,4,5,5),weight=c(0.5,0.35,0.5,0.9,0.6,0.6))), directed=FALSE) plot(G, edge.label=paste(E(G),"=",signif(E(G)$weight, digits=1)),

How can I use matplotlib with igraph?

和自甴很熟 提交于 2020-06-13 06:43:06
问题 How can I add statistical graphics (plots, axes, charts, etc) to an existing graphic implemented in python-igraph? I'm particularly interested in matplotlib because I have experience with this library. In my case igraph is being used for the different layout options. My current network has the x dimension partially constrained while y is changed by the layout. I would like to add a bar chart along the bottom of the diagram to list frequencies of the value tied to the x coordinate of the

Interactive UI with Igraph

余生长醉 提交于 2020-05-17 08:56:08
问题 Is there any tool which helps me create an interactive user interface for generating graphs using iGraphs for python? For instance can I use pyQt along with Igraph? 回答1: The Python interface of igraph uses Cairo as the drawing backend, so it can draw graphs on any surface that Cairo supports. It seems like someone else has managed to connect igraph's drawing surface to a gtk.DrawingArea , so that's one possibility if you are using PyGtk. As for PyQt and other drawing toolkits, I'm not sure

How to construct an edgeliste from a list of visited places (effectively)?

邮差的信 提交于 2020-05-15 09:35:11
问题 My original data.table consists of three columns. site , observation_number and id . E.g. the following which is all the observations for id = z |site|observation_number|id |a | 1| z |b | 2| z |c | 3| z Which means that ID z has traveled from a to b to c . There is no fixed number of sites per id. I wish to transform the data to an edge list like this |from |to||id| |a | b| z | |b | c| z | mock data sox <- data.table(site = c('a','b','c','a','c','c','a','d','e'), obsnum =c(1,2,3,1,2,1,2,3,4),

Find common neighbors of selected vertices

回眸只為那壹抹淺笑 提交于 2020-05-15 09:27:06
问题 I wrote a function that gets a list of vertices and an igraph weighted and directed graph. I want to find the common neighbors of input vertices. here is my function: commonNeighbors <- function(v,g) { library(igraph) library(dplyr) allNeigh <- list() for (i in v) { allNeigh <- append(allNeigh,c(neighbors(as.undirected(g),paste(i,sep=""))$name)) } allNeigh <- cbind(allNeigh) allNeigh <- table(as.numeric(allNeigh)) allNeigh <- as.data.frame(allNeigh) colnames(allNeigh) <- c('vertexID','freq')

How can I rearrange the order of edges in an igraph plot?

旧巷老猫 提交于 2020-03-01 06:48:44
问题 I'm trying to make a network plot in igraph that highlights certain important edges by coloring them differently than the others. For large graphs, they often get buried under the others. For example: library(igraph) test <- barabasi.game(200,m=2) E(test)$color <- "gray" E(test)[1]$color <- "red" sort(order(E(test)$color)[E(test)],decreasing=TRUE) plot(test, vertex.label=NA, vertex.shape="none", vertex.size=0, edge.arrow.mode=0, edge.width=2) gives me a plot where the single red edge is at