Questions tagged [adjacency-matrix]
A means of representing which vertices (or nodes) of a graph are adjacent to which other vertices.
873
questions
0
votes
1
answer
28
views
Co-occurrence matrix for text analysis in R (with visualisation)
I tried my best to find a solution by searching and googling, but unfortunately the solutions were either outdated (would not function) or not quite what I was looking for.
I think my question is ...
-1
votes
0
answers
28
views
How do you print the adjacency matrix graph?
So I'm making a code for a project and I ran into a problem. I cannot print the adjacency matrix graph. How do you print the Adjacency Matrix Graph?
public class Matrix {
String Graph = "...
0
votes
0
answers
32
views
Square proximity matrix
I am running a spatial EBLUP (sae package) and am having issues related to the proximity matrix.
I use the following code to build the adjacency matrix using my shapefile:
adjmatrix <- spdep::...
0
votes
0
answers
49
views
ALL shortest paths between a given node and a destination
I want an algorithm to find ALL the shortest paths between source S and destination E. I know that Dijkstra's algorithm can find one of the shortest paths, but I'm stuck at finding an algorithm for ...
0
votes
0
answers
25
views
How to create an adjacency matrix given a graph representation
We define the following string:
f = 'A2B2C2'
based on these rules:
each capital letter represents a block(so there are 3 blocks A B C)
each integer represents how many elements in one block, and ...
-4
votes
1
answer
38
views
I am trying to understand a code on adjacency matrix written in Java language ,I am not able to understand the enhanced for loop part [closed]
// Add edges
public void addEdge(int i, int j) {
adjMatrix[i][j] = true;
adjMatrix[j][i] = true;
}
// Remove edges
public void removeEdge(int i, int j) {
adjMatrix[i][j] = false;
...
1
vote
3
answers
69
views
Creating a directed adjacency matrix from a dataframe with many columns
I want to create a directed adjacency matrix from data like this:
x1
x2
x3
x4
x5
x6
x7
x8
1
1
1
1
1
1
1
2
22
22
22
3
3
3
2
3
3
3
3
5
5
2
3
23
Where the columns represent states in time.
The ...
0
votes
0
answers
19
views
How to change a dictionary into an adjacency matrix
I have a dictionary avgTE_data:
{'20180102': SYM_ROOT_i SYM_ROOT_j DATE_dat TE
0 A AAL 20180102 0.125528
1 A AAP 20180102 0....
0
votes
0
answers
30
views
Find shortest fastest path to go from starting point to destination point
from collections import defaultdict
class Graph:
def __init__(self, vertices):
self.V = vertices
self.graph = defaultdict(list)
def addEdge(self, u, v):
...
0
votes
0
answers
17
views
how to convert a matrix values in 8-connected with keeping the arrangement of x and y coordinates in python
I need to convert the boundary of polygon to chain code, and I would like to implement it in Python.
My input is "b" since the b is a numpy array by N*2 matrix that represent the boundary of ...
0
votes
0
answers
13
views
How to insert an error tapping in a graph and how to make a graph using edges and vertices
Can you please help me to put an error tarpping in my code. I have been doing it since yesterday but I think my braincell is already exhausted. Please send help po. And also can we print a graph in ...
0
votes
1
answer
35
views
Dataframe multiplication to create adjacency matrix
I am trying to create an adjacency matrix from an excel file that lists the IDs of school projects, their types, assigned students, their roles in the project, and their gender shown below:
[![sample ...
0
votes
1
answer
35
views
Creating adjacency matrix from sparse SKU data in Python
I have ecommerce data with about 6000 SKUs and 250,000 obs. Simple version below but a lot more sparse. There is only one SKU per line as each line is a transaction.
What I have:
|Index| ID | SKU1| ...
0
votes
1
answer
14
views
Time Complexity of Counting Length of Lists in Adjacency List?
Let's say I have an adjacency list, for example:
A1: b1 b2 b3
A2: b3 b4
A3: b4
A4: b1 b3 b4
What would be the time complexity to find the length of each 'sublist' in the whole adjacency list. The ...
0
votes
1
answer
63
views
Java adjacency matrix from .txt file won't read correctly
UPDATE: With the help of @KyreX the code now correctly reads the file and prints the array of names as vertexes HOWEVER it is now printing the entire array of names as vertexes instead of appending ...
0
votes
0
answers
40
views
Use affinity or adjacency matrix for Spectral Clustering?
I was wondering whether there is a reason for the adjacency matrix to be commonly used in Spectral Clustering, instead of the affinity matrix. As far as I understand, an affinity matrix is a weighted ...
0
votes
0
answers
33
views
Laplacian Eigenmaps Code does not calculate eigenvalues due to L matrix did not successfully constructed
Final resutls
Laplacian eigenmaps steps
creating omega matrix
1
vote
1
answer
66
views
Convert data frame into adjacency matrix format in R
My data looks like this:
Sample_A Sample_B Value
Rabbit Mouse 1.2
Mouse Tiger 7.89
Tiger Lion -0.9
Mouse Rabbit 1.2
Lion Rabbit 98.13
I ...
0
votes
1
answer
61
views
How to create an adjacency matrix from VTK / STL file?
I have a .vtk mesh with N points and F polygon (triangle) faces, and i'd like to build an N x N adjacency matrix to represent the connectivity between the points.
I've tried mesh.GetLines().GetData() ...
-1
votes
1
answer
83
views
How to find the list of edges incident to a particular vertex
I tried the following but I'm not sure that it is correct.
ArrayList<ArrayList<Integer>> list = new ArrayList<>();
public static ArrayList<ArrayList<Integer>> ...
1
vote
2
answers
50
views
Matrix that counts how many times the combination of a row and column of that matrix are present in a dataframe
I am still quite new with R so please bare with me :)
I need to create a matrix that counts how many times the combination of a row and column of that matrix are present in a dataframe.
As my ...
2
votes
1
answer
31
views
request symmetrical matrix in python
I'm doing some code to create a symmetrical matrix by request but I have an issue.
This is the code that I have. *** Is the code that maybe I have wrong and don't know how to fix it. I had try many ...
0
votes
1
answer
19
views
how I can do a request of a symmetrical matrix in python
I'm doing an excel matrix with python by request, but I need to do that the person typing the request put only 1 value and I fill the matrix with the same value in the 2 spots as a symmetrical matrix.
...
-2
votes
1
answer
30
views
how I can modify the diagonal of a request matrix to be zeros where i = j
I'm doing a matrix with python exporting at excel (library openpyxl) with a request by keyboard cell by cell.
My question is how in that request I don't request the diagonal of the matrix and instead ...
1
vote
0
answers
31
views
How I can set a specific cell from excel in python?
I'm doing a function with python where I have to create a matrix in Excel, but for that I need to know how I can manipulate some keyboard request to specific excel cells positions in it to create this ...
0
votes
0
answers
26
views
how i can solve TyperError: matriz_ady() missing 1 required positional argument: "x"
I'm sorry if my coding is awful, but I'm new at coding and I need some help with this error: TyperError: matriz_ady() missing 1 required positional argument: "x".
It's a graph problem where ...
0
votes
0
answers
43
views
Need help in calculating the adjacency matrix of a dataset
I have an image dataset which is 400 X 1024. So basically, each image is 32 X 32. What is the best method to calculate the adjacency matrix? I have already tried manually calculating it using ground ...
0
votes
0
answers
26
views
Creating adjacency matrix in python using sympy
I want to create an adjacency matrix in python and then proceed to study networks from there on. I wish to do so using sympy as I already developed a code to study eigenvalues and eigenvectors using ...
0
votes
0
answers
38
views
Is there a way to transform a distance matrix to a kneihbors graph using NearestNeighbors grom sklearn?
I'm trying to transform a distance matrix to a adjacency matrix using the k-nearest neighbors method. I'm trying to use the kneighbors_graph method from sklearn. However, in the documentation it says ...
0
votes
0
answers
18
views
How to learn the patterns from the time series of adjacency matrix?
I have a dataset with 100 nodes, each node has a time series as feature (yearly, 2010-2020, [11, 100]). Furthermore, these 100 nodes make a series of [100, 100] adjacency matrix (yearly, 2010-2020), ...
0
votes
0
answers
80
views
How to increase efficiency of Prim's algorithm used in finding minimum spanning tree from adjacency matrix of an undirected graph?
I have implemented an undirected graph using adjacency matrix. Now I want to find the edges in the minimum spanning tree that can be obtained by using Prim's Algorithm (along with priority queue). I ...
0
votes
0
answers
29
views
Floyd Warshall Algorithm returning None
def floydWarshall(self) :
n = len(self._W)
D = copy.deepcopy(self._W)
P = copy.deepcopy(self._W)
for i in range(n) :
for j in range(n) :
if i == j or self._W[...
1
vote
1
answer
107
views
Build an adjacency matrix from distances between cosmological objects
I'm probing into the Illustris API, and gathering information from a specific cosmos simulation, for a given redshift value.
This is how I request the api:
import requests
baseUrl = 'http://www.tng-...
1
vote
1
answer
243
views
generate adjacency matrix via networkx that has weights
I'm using the code below to generate some random Euclidean graphs. I expected the adjacency matrix to have the distances between nodes rather than just being a binary representation of the connections....
0
votes
0
answers
34
views
Generate digraph with given undirected girth
I need a python function to generate the adjacency matrix of a digraph given it's size n, it's undirected girth (minimal size of a undirected cycle) girth and a minimal out-degree delta.
I already ...
0
votes
0
answers
23
views
How to keep track of rows and columns of a matrix when turning it into a block diagonal one?
I am using scipy.linalg.block_diag function to create a block diagonal matrix from a given dataframe which has same number and label for its rows and columns. While the said function can create a ...
0
votes
0
answers
140
views
Graph Implementation with Adjacency Matrix and Strings
I'm trying to change my graph from accepting an integers as Vertices to strings. The folllowing is my Graph and Edge structures:
typedef struct GraphRep {
int **edges; // adjacency matrix ...
2
votes
0
answers
112
views
Python - Efficient algorithm to compute edge adjacency matrix (line graph)
Does anyone know an efficient algorithm to compute the edge-adjacency matrix (also known as the line graph L(G)) of a graph (G) starting from its traditional vertex-adjacency matrix?
By definition
...
0
votes
0
answers
9
views
Edges Recognition in textual graph representation
in textual graph representation, how to recognize that these two tokens can have edge among them?
I have searched in google and YouTube to find how the edges are established or created among two ...
0
votes
1
answer
182
views
How can I transform an adjacency matrix into an incidence matrix?
I created an adjacency matrix from an adjacency list, but I don't know how to create the incidence matrix from this data.
My code is this:
import numpy
graph = {'1': [{'2':'15'}, {'4':'7'}, {'5':'10'}...
0
votes
1
answer
103
views
How do i make adjacency Matrix with the given data
I have a gene interaction data like down below. Any idea how to make an adjacency matrix from this data?
1
vote
1
answer
19
views
Dataframe Adjustment
I have a dataframe with similar row and column labels just like any other square matrix as it follows:
a b c d e f
a 1 1 0 1 0 1
b 0 0 0 0 0 1
c 0 1 1 0 1 0
d 1 0 0 ...
1
vote
2
answers
149
views
generate random directed fully-accessible adjacent probability matrix
given V nodes and E connections as parameters, how do I generate random directed fully-!connected! adjacent probability matrix, where all the connections weights fanning out of a node sum to 1.
The ...
0
votes
0
answers
25
views
Balance speed & memory to compute non-redundant cosine similarity matrix
Suppose we have N items, where each consists of a 500-element vector. Now suppose we want to calculate all the cosine similarities for unique, unordered pairs and to skip the identity pairs (so for A, ...
0
votes
0
answers
73
views
More efficient Adjacency Matrix construction?
I have a pandas dataframe with the following structure:
U_OBS_ID
p_NODES
657984557613
[5459725, 149218120, 7799548]
376368450360
[7799548, 130844054, 3678, 87874, 35848191]
Basically, I have lists ...
0
votes
1
answer
206
views
Build edges with similarity value from adjacency matrix using NetworkX?
I have build a graph from nodes like:
data = pd.DataFrame({
'id': [1, 2, 3, 4, 5],
'a': [55, 2123, -19.3, 9, -8],
'b': [21, -0.1, 0.003, 4, 2.1]
})
import ...
0
votes
2
answers
71
views
Finding a pattern in a binary matrix with R
I have a nxn symetrical binary matrix and I want to find the largest rectangle (area) with 0 at the top-left and bottom-right corners and 1 at the top-right and bottom-left corner. If I just do it ...
1
vote
0
answers
137
views
Networkx - use multiple adjacent matrices to calculate node degree on a volume
I have 4 adjacent matrices obtained here link to matrices, which represent a distribution of dark matter, ordinary matter and magnetic fields at the present epoch, for a representative cosmic volume ...
1
vote
1
answer
89
views
Creating adjacency matrix with dirty dataset
This is the second time I am posting this question having deleted the first due to lack of reproducibility.
I referenced previously answered questions (Creating Adjacency Matrix and Social Network ...
1
vote
1
answer
61
views
Using a link agentset that has link weights to create an adjacency matrix in NetLogo
My understanding is that a link agentset is roughly equivalent to an edge list. In this case, I have links (3 breeds of them, but I think that's irrelevant) that have a variable, weight, that can be ...