adjacency-matrix

R: Adjacency list to Adjacency matrix

时光怂恿深爱的人放手 提交于 2019-12-08 04:13:49
问题 Bonjour, I would like to convert an adjacency list (3 columns ) to an adjacency matrix. In this forum I have found multiple examples on how to convert an edge list to an adjacency matrix. I successfully managed to do it for a two columns list. I have tried all the solutions I could find on the web but it seems that I missing a little step. What I tried My variables are User, Country, books User<-c("maman","sophia","Antoine") Country<-c("Canada","USA","Mexico") books<-c("Coelho","Rimbaud","The

The fastest way to calculate eigenvalues of large matrices

爷,独闯天下 提交于 2019-12-07 17:24:50
问题 Until now I used numpy.linalg.eigvals to calculate the eigenvalues of quadratic matrices with at least 1000 rows/columns and, for most cases, about a fifth of its entries non-zero (I don't know if that should be considered a sparse matrix). I found another topic indicating that scipy can possibly do a better job. However, since I have to calculate the eigenvalues for hundreds of thousands of large matrices of increasing size (possibly up to 20000 rows/columns and yes, I need ALL of their

Use shortest path to calculate probability of connection

自作多情 提交于 2019-12-07 14:58:51
问题 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

Building and adjacency matrix

落爺英雄遲暮 提交于 2019-12-06 16:54:05
问题 I was wondering if you guys can help me building an adjacency matrix. I have data in CVS format like this: Paper_ID Author 2 Foster-McGregor, N. 3 Van Houte, M. 4 van de Meerendonk, A. 5 Farla, K. 6 van Houte, M. 6 Siegel, M. 8 Farla, K. 11 Farla, K. 11 Verspagen, B. As you can see the column "Paper_ID" has a repeated value of 11, meaning that "Farla, K." and "Verspagen, B." are coauthors of a publication. I need to build a square weighted matrix using the names of the authors, counting the

R - Matching rows and colums of matrices with different length

感情迁移 提交于 2019-12-06 10:28:02
问题 my problem at the moment is the following. I have an directed 1-mode edgelist representing pairs of actors participating in joint projects in a certain year, which might look like: projektleader projectpartner year A B 2005 A C 2000 B A 2002 ... ... ... Now I need only a subset for one particular year. Not all actors are active in very year, so the dimensions of the subsets differ. For a following Network Analysis, I need a weighted and directed adjacency matrix, so I use the option of the

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

The fastest way to calculate eigenvalues of large matrices

折月煮酒 提交于 2019-12-06 01:17:24
Until now I used numpy.linalg.eigvals to calculate the eigenvalues of quadratic matrices with at least 1000 rows/columns and, for most cases, about a fifth of its entries non-zero (I don't know if that should be considered a sparse matrix). I found another topic indicating that scipy can possibly do a better job. However, since I have to calculate the eigenvalues for hundreds of thousands of large matrices of increasing size (possibly up to 20000 rows/columns and yes, I need ALL of their eigenvalues), this will always take awfully long. If I can speed things up, even just the tiniest bit, it

r creating an adjacency matrix from columns in a dataframe

我只是一个虾纸丫 提交于 2019-12-05 07:53:04
I am interested in testing some network visualization techniques but before trying those functions I want to build an adjacency matrix (from, to) using the dataframe which is as follows. Id Gender Col_Cold_1 Col_Cold_2 Col_Cold_3 Col_Hot_1 Col_Hot_2 Col_Hot_3 10 F pain sleep NA infection medication walking 14 F Bump NA muscle NA twitching flutter 17 M pain hemoloma Callus infection 18 F muscle pain twitching medication My goal is to create an adjacency matrix as follows 1) All values in columns with keyword Cold will contribute to the rows 2) All values in columns with keyword Hot will

Building and adjacency matrix

丶灬走出姿态 提交于 2019-12-04 21:49:59
I was wondering if you guys can help me building an adjacency matrix. I have data in CVS format like this: Paper_ID Author 2 Foster-McGregor, N. 3 Van Houte, M. 4 van de Meerendonk, A. 5 Farla, K. 6 van Houte, M. 6 Siegel, M. 8 Farla, K. 11 Farla, K. 11 Verspagen, B. As you can see the column "Paper_ID" has a repeated value of 11, meaning that "Farla, K." and "Verspagen, B." are coauthors of a publication. I need to build a square weighted matrix using the names of the authors, counting the times that they are collaborating together. Does the following do what you are looking for? # simulate

R iGraph: How to get weighted adjacency matrix from a graph?

我们两清 提交于 2019-12-04 05:35:51
问题 While there are some questions dealing with creating a graph from an adjacency matrix, I haven't found much about extracting the weighted adjacency matrix from a weighted graph. Say I have the following graph: library(igraph) nodes <- data.frame(name=c("a","b", "c", "d", "f", "g")) col1 <- c("a", "g", "f","f", "d","c") col2 <- c("b", "f","c","d","a","a") weight <- c(1,4,2,6,2,3) edges <- cbind.data.frame(col1,col2,weight) g <- graph.data.frame(edges, directed=F, vertices=nodes) E(g)$weight <-