Questions tagged [adjacency-matrix]

A means of representing which vertices (or nodes) of a graph are adjacent to which other vertices.

The adjacency matrix of a finite graph G on n vertices is the n×n matrix where the non-diagonal entry aij is the number of edges from vertex i to vertex j, and the diagonal entry aii, depending on the convention, is either once or twice the number of edges (loops) from vertex i to itself.

Undirected graphs often use the latter convention of counting loops twice, whereas directed graphs typically use the former convention.
There exists a unique adjacency matrix for each isomorphism class of graphs (up to permuting rows and columns), and it is not the adjacency matrix of any other isomorphism class of graphs.
In the special case of a finite simple graph, the adjacency matrix is a (0,1)-matrix with zeros on its diagonal.

If the graph is undirected, the adjacency matrix is symmetric.

The relationship between a graph and the eigenvalues and eigenvectors of its adjacency matrix is studied in spectral graph theory.

http://en.wikipedia.org/wiki/Adjacency_matrix

900 questions
9
votes
3 answers

Build a square adjacency matrix from data.frame or data.table

I am trying to build a square adjacency matrix from a data.table. Here is a reproducible example of what I already have : require(data.table) require(plyr) require(reshape2) # Build a mock data.table dt <-…
Vongo
  • 1,325
  • 1
  • 17
  • 27
9
votes
2 answers

using graph.adjacency() in R

I have a sample code in R as follows: library(igraph) rm(list=ls()) dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=T) # read .csv…
N D Thokare
  • 1,703
  • 6
  • 35
  • 57
8
votes
2 answers

How to compute the Topological Overlap Measure [TOM] for a weighted adjacency matrix in Python?

I'm trying to calculate the weighted topological overlap for an adjacency matrix but I cannot figure out how to do it correctly using numpy. The R function that does the correct implementation is from WGCNA…
O.rka
  • 29,847
  • 68
  • 194
  • 309
8
votes
1 answer

Sorting rows and columns of adjacency matrix to reveal cliques

I'm looking for a reordering technique to group connected components of an adjacency matrix together. For example, I've made an illustration with two groups, blue and green. Initially the '1's entries are distributed across the rows and columns of…
Cecilia
  • 4,512
  • 3
  • 32
  • 75
8
votes
3 answers

How to graph adjacency matrix using MATLAB

I want to create a plot showing connections between nodes from an adjacency matrix like the one below. gplot seems like the best tool for this. However, in order to use it, I need to pass the coordinate of each node. The problem is that I don't…
Charles Clayton
  • 17,005
  • 11
  • 87
  • 120
8
votes
1 answer

(OpenCV) Fast adjacency matrix computation from watershed

I would like to know if there is a faster way, than what I have done below, to compute the region adjacency matrix from a watershed image. Input: watershed image with N regions labeled from 1 to N. Output: adjacency matrix of these N regions. 1. For…
f10w
  • 1,524
  • 4
  • 24
  • 39
7
votes
3 answers

How to calculate a (co-)occurrence matrix from a data frame with several columns using R?

I'm a rookie in R and currently working with collaboration data in the form of an edge list with 32 columns and around 200.000 rows. I want to create a (co-)occurrence matrix based on the interaction between countries. However, I want to count the…
Seb
  • 179
  • 1
  • 8
7
votes
3 answers

Convert a DataFrame into Adjacency/Weights Matrix in R

I have a DataFrame, df. n is a column denoting the number of groups in the x column. x is a column containing the comma-separated groups. df <- data.frame(n = c(2, 3, 2, 2), x = c("a, b", "a, c, d", "c, d", "d, b")) > df n …
Rich Pauloo
  • 7,734
  • 4
  • 37
  • 69
7
votes
6 answers

Python Computing Vertex Degree Matrix

I am currently working on trying to write code to calculate the degree matrix, so that I may compute the Laplacian L = D - A, where D=degree matrix, A=adjacency matrix. This will be later used in my spectral clustering algorithm. I am using Python.…
ajl123
  • 1,172
  • 5
  • 17
  • 40
6
votes
2 answers

Is there any other Data structure to represent Graph other than Adjacency List or Adjacency Matrix?

I was looking for different Data structures for representing Graph and I came accross Nvidia CUDA Toolkit and found out new way to represent graph with the help of source_indices, destination_offsets. Fascinated by this innovative representation of…
6
votes
1 answer

r creating an adjacency matrix from columns in a dataframe

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 …
Lilla Bulten
  • 137
  • 1
  • 9
6
votes
2 answers

NetworkX: adjacency matrix does not correspond to graph

Say I have two options for generating the Adjacency Matrix of a network: nx.adjacency_matrix() and my own code. I wanted to test the correctness of my code and came up with some strange inequalities. Example: a 3x3 lattice network. import networkx…
FaCoffee
  • 7,609
  • 28
  • 99
  • 174
6
votes
2 answers

Need help getting to nth level of an adjacency matrix (graph) using a breadth-first search (Java)

public int bfs(int maxDepth){ int src = 2; int dest = 2; int i; int depth = 0; int countPaths = 0; int element; queue.add(src); while(!queue.isEmpty() && depth <= maxDepth) …
6
votes
1 answer

Create adjacency matrix in python from csv dataset

I have data that comes in the format as follows: eventid mnbr 20 1 26 1 12 2 14 2 15 3 14 3 10 3 eventid is an event that the member attended the data is represented as a panel so as you…
thyde
  • 111
  • 2
  • 8
6
votes
2 answers

Graph representation benchmarking

Currently am developing a program that solves (if possible) any given labyrinth of dimensions from 3X4 to 26x30. I represent the graph using both adj matrix (sparse) and adj list. I would like to know how to output the total time taken by the DFS to…
Carlos
  • 5,405
  • 21
  • 68
  • 114
1
2
3
59 60