igraph

How to assign different images to different vertices in an igraph?

隐身守侯 提交于 2020-01-11 02:36:40
问题 I've looked at this question which seems similar but I am having difficulty getting it to work with my data. Let's say my edgelist consists of the following: P1 P2 weight a b 1 a c 3 a d 2 b c 8 I use read.csv to collect the data, and then I convert it to a matrix. Then I graph it using the following: g=graph.edgelist(x[,1:2],directed=F) E(g)$weight=as.numeric(x[,3]) tkplot(g,layout=layout.fruchterman.reingold,edge.width=E(g)$weight) And this returns a network with vertices and edges. I would

Match vertex size to label size in igraph

风格不统一 提交于 2020-01-10 19:51:53
问题 I am trying to plot small networks using igraph in R. Each vertex in the network has a name, which is equivalent to its label. I would like to make each vertex have a rectangular symbol that is just large enough to fit its label. This is my main inspiration. What is the best way to do this with igraph? Edit: more information The code is here jsonToNM <- function(jfile, directed=TRUE) { # Requires "rjson" and "igraph" nm.json <- fromJSON(file=jfile) nm.graph <- c() # Initialize the graph with

Match vertex size to label size in igraph

情到浓时终转凉″ 提交于 2020-01-10 19:51:13
问题 I am trying to plot small networks using igraph in R. Each vertex in the network has a name, which is equivalent to its label. I would like to make each vertex have a rectangular symbol that is just large enough to fit its label. This is my main inspiration. What is the best way to do this with igraph? Edit: more information The code is here jsonToNM <- function(jfile, directed=TRUE) { # Requires "rjson" and "igraph" nm.json <- fromJSON(file=jfile) nm.graph <- c() # Initialize the graph with

R: potential issue with igraph 1.0.0 layout algorithms

霸气de小男生 提交于 2020-01-10 06:06:37
问题 Please load the following function: weight.community <- function(row,membership,weigth.within,weight.between) { if(as.numeric(membership[which(names(membership)==row[1])])==as.numeric(membership[which(names(membership)==row[2])])){ weight=weigth.within }else{ weight=weight.between } return(weight) } dump(weight.community,"weight.community.R") source("weight.community.R") Now, here is my issue: with igraph<1.0.0 , the following commands: g=erdos.renyi.game(10,0.5) V(g)$names=as.character(1:10)

How Igraph handle weights?

ぃ、小莉子 提交于 2020-01-06 08:44:34
问题 Good day to everyone. I have a really simple question that I wasn't able to find an answer, because of lack of terminology I am afraid. In r's package igraph how are considered weights? Are they considered a cost, therefore reducing the capacity of an edge or are they considered indeed as the capacity of the edge? Thank you very much 回答1: In igraph, weights are edge-attributes that represent the friction or cost of traveling that edge in a parth, not the capacity or bandwidth of the edge. Low

Loop or vector for creating multiple graphs for network analysis in R

六月ゝ 毕业季﹏ 提交于 2020-01-06 07:00:59
问题 I've created a graph from a dataframe with igraph that shows how students move between vocational courses. The first two columns are 'From' and 'To' which contain the qualification names (vertices) with an occurrence for each time a student enrols in a course for the first time (From) and then enrols in another (To). The remaining columns contain values relating to that particular student's demographics. I'd like to create and plot individual networks for movements 'To' OR 'From' each

Loop to create PDFs of each node in ego network with node ID as file names in R

允我心安 提交于 2020-01-06 05:57:45
问题 I'm creating ego networks from a graph in iGraph with R, as per the answer that was kindly provided to this question. I then want to export each ego network as a plot in a PDF or image file (preferably PDF). As there are 788 'ego networks' in the full dataframe I'd like to make the file name of the PDF match the relevant node ID for the network i.e. the 'From' column of the dataframe. Otherwise it's too hard to find the particular network that I want. How can this be done? Here's a sample of

R igraph : graph_from_incidence_matrix() and graph_from_adjacency_matrix() don't work [duplicate]

瘦欲@ 提交于 2020-01-05 13:55:25
问题 This question already has answers here : Error: could not find function … in R (10 answers) Closed 2 years ago . My igraph library doesn't recognize "graph_from_incidence_matrix() and graph_from_adjacency_matrix()" anymore (Everything else from igraph works fine). I've uninstalled and reinstalled igraph but still no luck. Here is an example: library(igraph) inc <- matrix(sample(0:1, 15, repl=TRUE), 3, 5) colnames(inc) <- letters[1:5] rownames(inc) <- LETTERS[1:3] graph_from_incidence_matrix

R igraph : graph_from_incidence_matrix() and graph_from_adjacency_matrix() don't work [duplicate]

六月ゝ 毕业季﹏ 提交于 2020-01-05 13:55:04
问题 This question already has answers here : Error: could not find function … in R (10 answers) Closed 2 years ago . My igraph library doesn't recognize "graph_from_incidence_matrix() and graph_from_adjacency_matrix()" anymore (Everything else from igraph works fine). I've uninstalled and reinstalled igraph but still no luck. Here is an example: library(igraph) inc <- matrix(sample(0:1, 15, repl=TRUE), 3, 5) colnames(inc) <- letters[1:5] rownames(inc) <- LETTERS[1:3] graph_from_incidence_matrix

bipartite graph matching to match two sets

匆匆过客 提交于 2020-01-05 09:02:12
问题 I'm a newbie to igraph package in R. I have two sets A and B , each with N vertices (A1, A2, ..., AN) and (B1, B2, ..., BN) . There is an edge between every element of A to every element of B , and I have a function fWgt(Ai, Bj) that returns the weights of the edge between Ai and Bj . I have been trying to use the igraph package in R to do a weighted maximum bipartite matching, but I haven't been able to formulate the problem as per the igraph package. For instance, in the example given for