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
2 answers

2D Object Array Memory Issues C++

When my input looks like this: 11 Harry Kate Fred Carol My adjacency matrix should put Harry at [7][7], Kate at [7][10], Fred at [7][5], and Carol at [7][2]. However, Carol & Kate get inserted at other locations within the adj. matrix as well. I am…
0
votes
0 answers

How to create boolean[] of all connected components of a given vertex?

Say I have an adjacency matrix boolean[][] adjMatrix = [n][n] and I want a function that returns a boolean[] of all the connected components of a given vertex. public static boolean[] connected(boolean[][] aMatrix, int vertexCount, int…
user1546716
  • 101
  • 1
  • 7
0
votes
1 answer

Best way to implement algorithm on Big Graph

We know that we can use adjacency list or adjacency matrix for algorithm on graph. It is pretty easy and straightforward for small graphs. But when the graph is very big, for example social network graph, what data structure should be best for…
0
votes
1 answer

Determining if Adjacency Matrix has certain Vertex

I am trying to come up with an algorithm that has to run in O(n) time and that determines if an adjacency matrix has a vertex that has 0 edges leaving (ie, the row of this vertex in the adjacency matrix is all false) and has all edges other than…
user3320687
  • 41
  • 2
  • 3
0
votes
3 answers

How to print matrix of a graph in R language

After loading external graph from disk as edgelist, I want to view the matrix format of this graph. Here is my steps: > rm(list=ls()) > data <- read.graph("c:\\temp\\graph.txt", format="edgelist") > adjm <- data.matrix(data) > adjm IGRAPH D--- 18…
shijie xu
  • 1,975
  • 21
  • 52
0
votes
0 answers

How to convert an edge list to an adjacency matrix in SAS?

I'm a beginner using SAS to perform network analysis. The data set is represented as an edge list in a CSV file, node1, node2, weight as each column. I want to convert this data set to an adjacency matrix, but I have no idea how to do it. Is there…
joyceXD
  • 65
  • 1
  • 2
  • 6
0
votes
2 answers

How can I get Euclidean distance matrix from adjacency matrix if the distance between neighbours is fixed to one

I have adjacency matrix,I don't know the location of the points only I know the adjacency matrix and distance between neighbors are equal. so how I get the distance between points??: is there any algorithm do that
0
votes
2 answers

Adjacency List: Path counter nonfunctional

I'm implementing a queue for an adjacency matrix, in a program that finds the shortest path between two nodes. But my path counter isn't being incremented and I can't see why. Any help would be greatly appreciated. Here's the file adj.data which the…
alldavidsluck
  • 77
  • 2
  • 3
  • 10
0
votes
1 answer

Add 1 to all values of a large adjacency matrix

I want to build a full graph out of an existing graph of a real network. The nodes have an attribute weight. The full graph should keep the same attributes of existing edges and set the weight of the new edges to 0. This solution works for small…
CptNemo
  • 6,455
  • 16
  • 58
  • 107
0
votes
3 answers

Please explain me what is hapenning in line 3 of this code

Please explain me what is hapenning in line 3 of this code. for my $i (0 .. $dim) { for my $j (0 .. $dim) { $adj->[$i][$j] = $adj->[$i][$j] ? [$j] : [];
0
votes
0 answers

Bidirectional Implementation of Dijkstra's Algorithm in C++

I recently just started to learn c++ and for my next homework assignment I have to implement a bidirectional version of dijkstra's algorithm. I'm supposed to build on my last assignment which makes a graph using vectors. I'm wondering what the best…
0
votes
0 answers

Grid and adjacency matrix in java

Need little help with my programming. I'd like to create a grid with n columns and n rows. A also would like to show or print adjacency matrix.For start I did create some code, but the results are not correct, and I don't know hot to fix it. I need…
Phantom
  • 87
  • 3
  • 13
0
votes
0 answers

Finding the girth g(G) (if there is one) and diameter diam(G) on a Graph in Adjacency Matrix [Java]

Really stumped on this one, don't know where to begin. I thought about making a separate method which calculates the paths between two different vertices, but I don't know how I would implement that. I thought that finding the minimum degree of the…
0
votes
1 answer

Why would I need BFS or DFS if I have direct access to the vertices and edges?

I am implementing an intercity map using graphs. Since it is undirected, I used an upper triangular adjacency matrix using a vector of vertices and vector of 'pointer to array of edges' in the Graph class. I need to traverse such a graph. Vertices…
0
votes
1 answer

why can´t it be an undirected graph?

I´m stuck here with a question I cannot resolve. the question is why can´t this matrix be an undirected graph? [ [0,1,0], [1,1,1], [0,0,0] ] I was told by my teacher that it can´t be an undirected graph. I have to explain why but I really don´t…
stu
  • 33
  • 2
  • 5