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
110
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
130
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
58
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
100
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 ...
0
votes
1
answer
93
views
r adjacent matrix plot with cell colors
I have a nxn dataframe as follows
Col1 Col2 Col3 Col4 Col5 Col6
Col1 0 0 0 0 0 0
Col2 0 0 0 0 0 0
Col3 0 ...
-1
votes
2
answers
110
views
Create list of items repeated N times without repeating itself
I would like to repeat a list N times but without repeating an item itself. For example,
from itertools import *
items = [ _ for _ in range(3)]
# repeat each item twice
row = sorted(list(chain(*...
0
votes
0
answers
42
views
Simplifying equations created from a matrix
Good day! I'm trying to write a python script that can model the temperature of a space.
I've chosen an 11x11 matrix to represent this space, the edges are 20 degrees, and the centre is 3000 degrees.
...
1
vote
0
answers
57
views
Bug inside Prim's MST algorithm in Java using Adjacency Matrix
I'm trying implement Prim's Minimum Spanning Tree Algorithm of a graph represented using Adjacency Matrix in Java. The code is running successfully, but not able to generate expected output. The ...
0
votes
1
answer
466
views
Optimal way to build adjacency matrix from image
I am trying to build an adjacency matrix from pixels of an elevation raster. The raster is a GeoTIFF image with specified nodata values outside a watershed.
The solution I have now is working but is ...
0
votes
0
answers
64
views
Reodrering a massive sparse stiffness matrix
I have assembled a massive sparse stiffness matrix using its DOFs and some rules of assembly. In order to do an efficient Bragg scattering analysis, I would now like to reorder them based on 3 zones: ...
2
votes
1
answer
75
views
Python code for calculation of very large adjacency matrix crashes using networkx MultiDiGraph
I need to calculate the adjacency matrix (in flat format) of a very large graph. Number nodes is 54327 and number edges is 46 million. The input are 46 million edges, so input looks like
1 6
2 7
1 6
3 ...
2
votes
2
answers
92
views
Code for weighted adjacency matrix from df with 8 columns of string data?
I really need help with code to create a weighted adjacency matrix from a dataset; some rows contain 1 or 2 ingredients, but others have more (up to 8). The resulting matrix will likely be upwards of ...
0
votes
2
answers
108
views
Make a adjacency matrix from dataframe when rows are equal
I have a dataframe similar to
mydf <- data.frame(Country=c('USA','Brazil','China','Italy','Ghana','Brazil','USA','China','USA'),
Pattern=c('XXZ','XXX','XYX','XXZ','...
1
vote
0
answers
108
views
error in running spatial regression model
I am doing empirical research on the impact of wind turbine proximity on property values. I've built the spatial lag, error, and SAC models. My problem is that, after specifying the weights matrix, I ...
1
vote
0
answers
116
views
How do I find a Hamiltonian Cycle in a Graph in C# when some nodes branch to a connected loop of nodes?
I have this graph:
The starting node is Hotel and I want the program to find paths for all valid Hamiltonian cycles.
But I cannot seem to get the code to work despite following examples of the ...
1
vote
2
answers
151
views
Boost Graph Library: subgraph isomorphism with adjacency_matrix
I am using Boost 1.83 with the latest Cygwin. The problem I'm having also occurred with Boost 1.66.
I am trying to use the Boost Graph Library isomorphism function on an adjacency_matrix:
#include &...
0
votes
1
answer
63
views
NetworkX gives wrong edge indices
I have the following function taking two NetworkX graphs as input.
I debug printed the adjacency matrix and the edges returned by NetworkX, which do not match. If I hardcode the adjacency matrix, ...
0
votes
0
answers
61
views
Get the adjacency matrix for a Squared Grid
In a grid LxL where L is the square root of the number of elements N (L=numpy.sqrt(N)) i want to obtain the adjacency matrix for all the points that are close to each other, including the diagonals.
I ...
0
votes
0
answers
57
views
Adjacency Matrix for Undirected Graph (Collaboration network of Arxiv General Relativity)
I want to use MATLAB to create the adjacency matrix for the following undirected graph data in this link.
When I apply "graph" function, I get the error that the matrix has duplicate edges. ...
3
votes
3
answers
77
views
Token string cuts off when inserting into 2d array in C
I am correctly tokenizing single words from a line of strings; however, inserting them into a 2d array cuts off parts of the token. I also have a problem with NULL, and the code results in a segfault.
...
-1
votes
1
answer
163
views
How to stop Igraph generating duplicate vertices from adjacency matrix?
I am attemping to create a weighted social network between a series of characters.
I have manually created an adjacency matrix with weighted values:
. This has been linked to a separate file, in which ...
0
votes
1
answer
91
views
Create adjacency matrix from a list of Id and the corresponding club they are part of
The structure of the data in Stata looks something like this:
id club_id
1 1
2 1
3 2
4 2
5 2
6 3
7 3
8 3
9 3
I assume that the network ...
0
votes
1
answer
230
views
How to optimize memory footprint of a graph with large amount of vertex?
I was tasked my my prof to solve a graph question. However, he hinted that one of his hidden test cases that I failed have over 80k, my code would fail as it exceeded the amount of memory that was ...
1
vote
1
answer
671
views
How to get the path from the Dijkstra algorithm in Python
I took the code for the Dijkstra algorithm from this website and rewrote it for my needs (see below). Now I need to implement a feature that would store the shortest path for each node. I tried ...
1
vote
1
answer
293
views
Printing all the cycles in an adjacency matrix using python
In the below code, while trying to print all cycles, there comes the case where multiple cycles exist for one node. Even though I am increasing the value of k in the cycle function, it doesn't print ...
1
vote
0
answers
58
views
How Can I find neighbors positions of 2d array using depth first search
I just need to find neighbors positions of 2d array using depth first search.
for example assume below one is the 2D array.
{{0,0,0,0,0,},
{0,1,1,1,0,},
{0,1,1,1,0,},
{0,1,1,1,0,},
{0,0,0,1,1,},};
...
0
votes
1
answer
142
views
DBSCAN but grouping points that are mutually close?
I have an adjacency matrix which I am using as my pre detriment distance matrix. Instead of finding all the nearest points of all the nearest points I only want to group points that are all near each-...
1
vote
1
answer
584
views
Assigning Values so that Sum of Each Rows and Columns in Matrix is the Same
I have an adjacency matrix below (both column & headers are userIDs) with values either 0s or 1s. The value 1 denotes that the 1st user knows the 2nd user and vice versa (e.g User 0 knows User 1 ...
1
vote
1
answer
114
views
Bitwise operation on a dynamic data structure
I am implementing a simple document indexer for information retrieval. Now I need to implement an incidence matrix, that should be able to be extended dynamically (not satisfied with just a static ...
1
vote
1
answer
155
views
Adjacency matrix manipulation and connectivity Index
Hope you are well. I've been converting an adjacency matrix to a connectivity index. I am having problems trying to get it take the second neighbour, but have been having issues. I will try to explain ...
0
votes
1
answer
143
views
adjacency matrix based on multiple columns
I have a data frame with more than 20 columns of actor names and I would like to make the adjacency matrix for the relationship among them, for the sake of simplicity let's say my data frame is as ...
1
vote
1
answer
92
views
Creating a network in Python
I am creating a network by specifying points and edges. However, I want to make this code more generic so that it can handle large number of my_nodes (say 100) and generate a connection matrix. This ...
0
votes
2
answers
216
views
Generating a specific adjacency matrix in Python
I have a network with nodes and vertices and the following numbering scheme. I want to generate an adjacency matrix A for the nodes 0,1 as shown below. I tried to do using networkx. I present the ...
1
vote
1
answer
550
views
Adjacency matrix using numpy
I need to generate the following adjacency matrices:
No of Nodes = 3
A B C AB AC BC
A 0 1 1 0 0 1
B 1 0 1 0 1 0
C 1 1 0 1 0 0
AB 0 0 1 0 0 0
...
1
vote
1
answer
106
views
Building adjacency matrix in python
I have a origin & destination airport and the number of flights between two airports on a certain year.
ORIGIN_AIRPORT DESTINATION_AIRPORT Counts
0 ABE ATL ...
0
votes
1
answer
88
views
Effectively create adjecency matrix from lists of neighbors from multiple CSVs
I have a large collection of CSVs, each containing
an "id" column of values, and
a "neighbors" column with lists of strings.
Values from id do not occur in any neighbors lists. ...
0
votes
0
answers
69
views
How to change from user input of adjacency matrix into hard coding it into the program?
try
{
System.out.println("Enter the number of vertices");
number_of_vertices = scan.nextInt();
adjacency_matrix = new int[number_of_vertices + 1][number_of_vertices + 1];
...
2
votes
3
answers
820
views
How can i plot an undirected connected graph in R?
I want to plot graph (which is an undirected connected graph) like the uploaded picture.
I want to use the adjacency matrix in order to plot it.
So my question is how can I plot a graph from its ...
0
votes
1
answer
34
views
Why am I not able to see the random numbers generated using python for large input values? [duplicate]
So I am trying to generate my own adjacency list using random.randint. I am not able to view the output.
Its just few values and then dots. I want to input these values into my algorithm. How to view ...