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
-1
votes
1 answer

How to convert a scalar index to a 2 dimensional index in numpy

Let's say we have a set of N nodes that can be coupled, as in a complex network, and we don't care of the direction of the link (so the link between 1 and 2 is the same as 2 and 1). I want to use a numpy one-dimensional array to represent the state…
wetrust
  • 57
  • 7
-1
votes
1 answer

Dijkstras algorithm implementation in C giving wrong (but almost right) output

I am trying to implement Dijkstras algorithm in c and I almost have the right output. Something is happening it the dist array. It is giving extremely large and small numbers. Link to site I'm basing most of my algorithm code on:…
Helana Brock
  • 45
  • 15
-1
votes
1 answer

C program doesn't start, implementing Dijkstras algorithm

I am doing an assignment for class that is supposed to be coded a very specific way. Here is the goal: Goal: To implement Dijkstra’s algorithm for single source shortest path problem for a given directed graph using an adjacency matrix…
Helana Brock
  • 45
  • 15
-1
votes
1 answer

How to make an adjacency matrix out of a list from a file in C

Hey I want to make an adjacency matrix out of the list from a file in c but I am not sure how to do it. This is my code so far: #include #include typedef struct value { int num; char start_vertex[250]; char…
-1
votes
1 answer

Can i change value of Adjacency Matrix on Python Programming?

I have problem with my code, i cannot print or change value of Adjacency matrix, can you help me sir? i have code like this for i in range(len(A.todense())): for j in A[i].todense()*1: print(j) and the output is [[0 0 0 0 0 1 1 0]] [[0…
-1
votes
2 answers

How to create an adjacency matrix based on a condition in R?

I came across the Q&A: Possible-clique-numbers-of-a-regular-graph. I have a vec vector and I need to create a adjacency matrix A such that A[i,j]=1 if i−j mod n is an element of vec and A[i,j]=0 otherwise. My attempt: k <- 4 n <- 10 vec <-…
Nick
  • 1,086
  • 7
  • 21
-1
votes
2 answers

Is there a R package to assist in large data processing?

I am processing a large dataset (after being cleaned). The data set is then processed to create an adjacency matrix, which is passed a logicEval to id obs that contain the uniqueID. 5 When running the code snippet to create adjacency matrix, the…
OctoCatKnows
  • 399
  • 3
  • 17
-1
votes
1 answer

Creating adjacency matrix from 4x6 matrix

I have a 4x6 matrix (directed network) similar to the following example:So first column represent individuals and each rows represent individual friendship with other individuals so first row represent individual 1 friendship with 2 and 5 and…
-1
votes
2 answers

Task graph implement

I would be thankful if someone could help me with this Task. Task: Implements a class Graph (directed and weighted), without using the standard Graph-classes of java. Doesn't matter using adjacencyList or adjMatrix My Code import…
VisionTrek
  • 13
  • 3
-1
votes
1 answer

C/C++ Finding all paths between two vertex in unweighted & undirected graph using an adjacency matrix

I'm trying to find all paths between a starting vertex and an ending vertex using an adjacency matrix. My graph is unweighted & undirected. I was trying to follow this algorithm but, I got stuck at the for each part. Algorithm: procedure…
-1
votes
2 answers

Creating undirected weighted graph from adjancency matrix from a csv

I want to create undirected weighted graph of a given adjacency matrix by reading it from a csv. I can read it from a csv but I don't know how to draw its in graph. This is code for reading file. int main(){ ifstream ip("map.csv"); …
shahid hamdam
  • 751
  • 1
  • 10
  • 24
-1
votes
2 answers

R adjacency matrix from neighboring list

I have created a neighboring list from mydata using: neighbors <- get.knn(mydata, k=5) it looks like this: [,1] [,2] [,3] [,4] [,5] [1,] 12 80 39 82 41 [2,] 133 52 10 58 150 [3,] 47 59 18 129 72 [4,] 48 150 84 …
Coav
  • 1
  • 1
-1
votes
3 answers

How to remove the unconnected nodes from an adjacency matrix?

I have an adjacency matrix(n*n) of 1's and 0's extracted from an unweighted and undirected graph, my goal is to remove all-zeros columns from this matrix and their corresponding rows which are not connected to any node from the graph. I want to…
F.caren
  • 85
  • 1
  • 9
-1
votes
1 answer

How to generate random 3D-graph and displays its adjacncency matrix in matlab

I have generated 3D points in matlab. I need it to be form random graph and display its connectivity such that connected link is 1 and 0 otherwise.. suggestions..…
-1
votes
1 answer

How to convert Text file data into Adjucency list

I have following Graph Text file, It is big file I want to convert into adjacency List in scala. First few lines of the text file given below: src, dst,dist A,C,5.0 A,B,8.0 B,C,6.0 B,D,7.0 B,A,8.0 C,A,5.0 C,B,6.0 D,B,7.0 D,E,8.0 E,D,8.0 I want to…
Yasir Arfat
  • 645
  • 1
  • 8
  • 21