915 questions
5 votes
2 answers
209 views
Calculate distances between GPS relocations of animals that belong to groups of social network analysis
I have a dataset of 150 individual cows (150 IDs) with 288 GPS locations per day and for 10 days, where each row is a relocation (432.000 rows) and columns store cow's ID, a time stamp (date and time)...
3 votes
2 answers
109 views
How to vectorize computation of spearman correlation between a 2D array and a reference 1D array with scipy
I have a matrix M with size (37, N) and an additionnal 1D reference vector of size (37,1) I am looking for a way to compute the spearman correlation between each sample of M and my reference to obtain ...
1 vote
1 answer
81 views
graph-tool not plotting/visualizing adjacency matrix correctly
I am using graph-tool to plot an adjacency matrix from a dataframe. The adjacency matrix looks correct and symmetric, but when I plot it using graph-tool, the resulting visualization is incorrect. (I ...
2 votes
2 answers
67 views
Random adjacendy matrix from list of degrees
I want to do exactly the same thing as this post, but in python; aka given a list of natural integers, generate a random adjacency matrix whose degrees would match the list. I had great hope as the ...
1 vote
1 answer
128 views
How to convert a graph into a sparse adjacency matrix having a given type (other then "dgCMatrix")
How to convert a graph to a sparse ‘dgTmatrix’ in one step? library(igraph) library(Matrix) g <- make_ring(5) adj <- as_adjacency_matrix(g, sparse = TRUE) class(adj) # [1] "dgCMatrix" #...
1 vote
0 answers
34 views
Generalising the adjustments to the Trace of the Adjacency matrix to find the number of genuine loops of a particular size in an undirected network?
It's relatively easy to see that, for a network with Adjacency matrix A, the number of 3-loops is (1/6)Tr(A^3). For 4-loops, we need (1/8)[Tr(A^4) - 2(sigma(k^2)) + sigma(k)] where k are the node ...
0 votes
0 answers
85 views
Add adjacency matrix in Voronoi
The data x and y represent the geographic coordinates of the centroids of cities 1 to 8: > df <- data.frame( + ID = 1:8, + x = c(4.0, 7.0, 2.5, 8.0, 3.0, 5.0, 6.0, 7.0), + y = c(8, 9, 4, 5,...
0 votes
1 answer
54 views
How to create a summed adjacency matrix in R
I have a dataframe that consists of x rows and n columns. Each row represents a document and each column represents a category of tag associated with the document. The values in each cell are a 0 (...
0 votes
1 answer
54 views
Make index and columns the same set (their union) in Pandas dataframe
In our problem, rows (index) and columns belong to the same category of objects. We want to enlarge a Pandas DataFrame, adding rows and columns filled with NaNs or predefined values, so that both the ...
3 votes
3 answers
99 views
Preparing adjacency matrix - Filling missing links
I have a dataframe of this structure: A <- data.frame(A = c("B",NA,NA,NA), B = c("C","D",NA,NA), C = c(NA,NA,NA,NA), ...
0 votes
1 answer
240 views
Classification using Graph Neural Network
I am working on a fraud detection project using GNN. My graph has banking codes (SWIFT BIC codes) as nodes and the edges represent transactions. Below are the shapes of my tensors: Node Features ...
2 votes
2 answers
84 views
Recursive matrix construction with numpy array issues (broadcasting?)
The following is a seemingly simple recursion for finding a hybercube matrix. The recursion is defined as: (Formula) I tried to put it into code but I keep running into broadcasting issues with numpy. ...
0 votes
1 answer
59 views
How to construct multiple bar plots overlaying rows with a data frame that has incidence matrix structure
For the follwoing data that represents the flow of the tourist by months for these five countries, I would like to draw a multiple bar plot such that one row of the mutliple bar plot represents the ...
1 vote
3 answers
210 views
Parameterizing type definition at compile time
What is a good way to define this graph data structure: typedef struct { unsigned short isExists : 1; WEIGHT_TYPE weight; } Weight; typedef struct { Weight adjacencyMatrix[VERTICES_NUM][...
0 votes
1 answer
77 views
Scikit-learn : Exception when calling fit_predict on a PageRank object with a small edge_list
I'm experiencing a strange exception when calling the fit_predict method on a PageRank object, with data coming from an edge list. I get the 'TypeError: The input matrix must be in Scipy sparse format ...