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

Using NetworkX all_simple_paths gives AttributeError

I have a graph with adjacency matrix of the form below (a 6-node graph where self-edges are 0 and no_connections are marked Inf and other edges are 1): {1: {1: 0, 2: 1, 3: inf, 4: inf, 5: inf, 6: inf}, 2: {1: 1, 2: 0, 3: inf, 4: 1, 5: 1, 6: inf}, 3:…
Ezzat Zar
  • 3
  • 2
0
votes
1 answer

shortest path between two strings

I am having to do a problem which creates the adjacency matrix the finds the shortest path between to strings that the user enters. I have already read the data file full of strings and have built the adjacency matrix if the shortest path between…
Chewy
  • 11
  • 1
  • 5
0
votes
1 answer

How to get adjacency matrix of each detected cluster in R?

Is there a simple way to convert each cluster detected by an k-means to an adjacency matrix in R?
Camilla
  • 117
  • 1
  • 10
0
votes
1 answer

igraph R and C, writing and reading adjacency matrix with attributes

I would like to use igraph R to visualize a network graph which I create with igraph C. So far I have saved the graph in C with these commands: FILE *ofile; ofile=fopen("AdjacencyMatrix.csv", "w"); igraph_write_graph_pajek(&g,…
Niccola Tartaglia
  • 1,537
  • 2
  • 26
  • 40
0
votes
2 answers

Simple recursive function to determine if two elements are transitively true

newbie here. Even newer to recursion. I'm writing a function for my C++ program, and as you'll be able to tell, I'm a bit clueless when it comes to recursive algorithms. I'd appreciate it greatly if someone could fix my function so I can get it…
0
votes
1 answer

Convert adjacency matrix to specific edge list in MATLAB

If I have the matrix 1 0 0 0 0 1 0 0 0 and I want this form in MATLAB 1 2 3 1 2 3 1 2 3 1 1 1 2 2 2 3 3 3 1 0 0 0 0 0 0 1 0 also I want the values of third row in result. i.e. ans= [1 0 0 0 0 0 0 1 0]
Asmaa Daoud
  • 69
  • 2
  • 8
0
votes
0 answers

bfs using queue not working properly

I'm implementing BFS FOR adjacency matrix using queue in C and here is my code #include #define MAX 10 int G[MAX][MAX],n,visited[MAX]; typedef struct queue{ int front,rear; int data[MAX]; }q; q p; void bfs(int); void…
Ayush Goyal
  • 415
  • 4
  • 23
0
votes
1 answer

Create a random graph or its corresponding adjacency matrix from a given degree list

I have the following problem in R: I have a vector that contains the degrees of 200 nodes in my graph. Strictly speaking should they present out-degrees. Is it possible to create from these existing degrees for the nodes i = 1, ...,200 a random…
Fulla
  • 17
  • 6
0
votes
1 answer

reordering the symmetric adjacency matrix including +1 and -1 elements to get cliques

I have a symmetric adjacency matrix with zero value on its diagonal. now i am looking for reordering method to show community which divides the matrix in two cliques with +1 and -1 values respectively. it would be appreciated if someone could help…
sahar
  • 3
  • 3
0
votes
1 answer

create adj-matrix and adj-list?

How to write pesoduocode for following graph ! Figure 23.2 http://staff.ustc.edu.cn/~csli/graduate/algorithms/book6/chap23.htm here what I have // adj-list for each u ∈ v [G] do empty list Adj-list[u] for each u ∈ v [G] do if (u,v) ∈ E //if there is…
As123
  • 11
  • 1
  • 6
0
votes
0 answers

Generating large adjacency matrix

I'm trying to generate a adjacency matrix from a csv. The csv contains 2 columns, 1 for users and 1 for projects. The two columns form a bipartite graph, where each user can be part of multiple projects or none at all, but no edges between nodes of…
0
votes
1 answer

Segmentation fault when adding edge to graph

I have to use an undirected weighted graph (adjacency matrix) for this program. typedef struct graph { int n; /* Number of vertices */ Boolean *visited; /* Will be later used */ double **mat; /* It has to be a double */ }…
0
votes
1 answer

scala: adjacency matrix graphs

I am trying to understand how to build graphs in Scala, till now I have this: import scala.collection.mutable.ArrayBuffer object TestGraph { class Graph(vertices: Array[String], edges: ArrayBuffer[(Int, Int)]) { def size: Int =…
Valerin
  • 465
  • 3
  • 19
0
votes
1 answer

Dijkstra's algorithm - adjacency matrix and list

I've got strange problem with my Dijkstra's implementation... I have 2 algorithms, one for adjacency matrix and the second one for adjacency list. They are almost identical and only difference is with passing numbers from these structures. I keep…
DzikiChrzan
  • 2,747
  • 2
  • 15
  • 22
0
votes
1 answer

adjacency matrix find if neighbores

I have some homewrok that looks like this: Question 1 ( First program adjacency.c file ) Directed tree structure T has N nodes represented by the adjacency matrix A size NxN as follows: A [ u ] [ v] == TRUE if and only if there is a directed arc…
user4831626
  • 9
  • 1
  • 1
  • 6