igraph

Output shapefile for the igraph network in R

别来无恙 提交于 2019-12-30 04:44:05
问题 Hello I have a network in R using the igraph library Vertices: 616 Edges: 6270 Directed: TRUE No graph attributes. Vertex attributes: name, Lat, Lon. Edge attributes: V3. How can I generate two shapefiles for the Vertices and the Edges using the Lat, Lon info in the vertex? 回答1: You can do this using the sp and maptools packages. There are handy functions writePointsShape() and writeLinesShape() in maptools that will write to the ESRI shapefile format. Before doing this, it is necessary to

Error with igraph library - deprecated library

感情迁移 提交于 2019-12-30 00:26:27
问题 I have changed my computer to a Linux Mint x64 OS and I have throubles with a python library, igraph library, when i try to execute and old program I made. DeprecationWarning: To avoid name collision with the igraph project, this visualization library has been renamed to 'jgraph'. Please upgrade when convenient. I can't find information about how to change my code for the new library. On a Win8 PC, via pip installation, it works perfectly but I can't make it working on my PC with Mint. The

How to fix nodes when plotting a subset over a complete network using igraph R

亡梦爱人 提交于 2019-12-29 08:50:09
问题 I have a problem concerning network visualization using the igraph package provided in R. Assume that you have a certain network, which contains the total sample of nodes and edges. Let me name this network netX: netX <- structure(c(1, 0.48275862, 0.51724138, 0.48275862, 0.27906977, 0.06896552, 0.34482759, 0.32352941, 0.06896552, 0.34482759, 0.03448276, 0.06896552, 0.20689655, 0.17241379, 0.17241379, 0, 0.23333333, 0.27586207, 0.21621622, 0.24137931, 0.48275862, 1, 0.4137931, 0.35714286, 0

Visualizing distance between nodes according to weights - with R

穿精又带淫゛_ 提交于 2019-12-29 06:59:47
问题 I'm trying to draw a graph where the distance between vertices correspond to the edge weights* and I've founde that in graphviz there is a way to draw such graph. Is there a way to do this in R with the igraph package (specfically with graph.adkacency)? Thanks, Noam (as once have been asked: draw a graph where the distance between vertices correspond to the edge weights) 回答1: This is not possible as you need triangle equality for every triangle to be able to plot such an object. So you can

R igraph rename vertices

我只是一个虾纸丫 提交于 2019-12-28 18:05:34
问题 Is there a possibility to rename the vertices in an igraph. I want to plot a certain graph multiple times with different notation on the vertices. Given the following igraph az: > az IGRAPH DN-- 24 23 -- + attr: name (v/c), label (v/c), color (v/c), fill (v/c), width (e/n) with > V(az) Vertex sequence: [1] "x1" "x2" "x3" "x4" "x5" "x7" "x8" "x9" "x10" "x11" "x12" "x13" [13] "x14" "x15" "x16" "x19" "x20" "x21" "x22" "x23" "x24" "x25" "x26" "x27" I want to change the vertices into, lets say to

Correctly color vertices in R igraph

ⅰ亾dé卋堺 提交于 2019-12-28 04:23:07
问题 I am using igraph to color vertices I have two CSV files answers and topology of the graph. Answers: (this tells that players K and N answered correctly) Player Q1_I1 1 k 1 2 l 0 3 n 1 4 m 0 Topology: (representation of who is connected to whom) Node.1 Node.2 1 k l 2 l k 3 l m 4 m l 5 l n 6 n l 7 n k 8 k n I wanted to build a graph using package IGraph and to color vertices in different colors depending of their correctness. This is what I was able to achieve: # reads answers and creates a

R: arulesviz and igraph causing a conflict

亡梦爱人 提交于 2019-12-25 08:58:30
问题 I am trying to visualise the "groceries" dataset. library(arules) library(arulesViz) library(datasets) rules <- apriori(Groceries, parameter = list(supp = 0.001, conf = 0.75)) rules<-sort(rules, decreasing=TRUE,by="confidence") plot(rules, method="graph", interactive = TRUE, shading = NA) On running this, I get an error about the igraph package. Error in igraph::tkplot(g, ..., layout = igraph::layout_(g, control$layout), : tcl/tk library not available What could be the reason for this error?

Generate colors based on unique entries in another list in R

亡梦爱人 提交于 2019-12-25 08:13:50
问题 I want to use a color palette to define colors for my graph edges in igraph . I have create the color palette using RColorBrewer and need to assign a unique color to each edge based on edge attribute information. Here is my attempt so far: colrs<- brewer.pal(length(unique(E(g)$fruit)), "Accent") E(g)$color <- colrs[E(g)$fruit] #Does not work E(g)$color [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [40] NA NA NA NA NA

How to complete a graph assigning 0 as weight attribute of new edges

萝らか妹 提交于 2019-12-25 07:48:19
问题 Please consider the following graph library(igraph) g <- erdos.renyi.game(100, 2/100) E(g)$weight <- sample(1:10, ecount(g), replace=TRUE) I am interested in "completing" the graph by adding all missing edges (as a result each pair of vertices will be connected by an edge) but making sure the new edges are assign E(g)$weight = 0. Is it possible? 回答1: This should work. olde = E(g) # saving edges g[V(g), V(g)] <- TRUE # adding all possible edges E(g)$weight <- 0 # all weights is 0 E(g)[olde]

How to write a dataframe, graph to pajek format?

我们两清 提交于 2019-12-25 05:32:29
问题 I Would like to save a igraph graph or a dataframe to pajek format. So I have used the igraph package to create graph object and then used this write.graph(graph_activitynetwork,"layer_share","pajek") to write the igraph graph in pajek .but what I am wondering is to create it in customized format :like this : *Vertices 4 1 "Node 1" 2 "Node 2" 3 "Node 3" 4 "Node 4" *Multiplex # layer node layer node [weight] 1 1 1 2 2 1 1 2 2 1 1 2 1 1 1 now I could just have this format : *Vertices 4 1 "1" 2