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

Implementing Depth First Traversal for a Graph using Adjacency Matrix C++

I have got a set of nodes and few edges that represent which nodes are connected. V_nodes 1 7 22 97 48 11 V_arcs (1 22) (97 22) (7 1) (11 48) (48 7) (11 0) V_weight 1 I have created its adjacency matrix that shows 1 for connected and 0 for…
Faizan
  • 1,847
  • 8
  • 40
  • 63
0
votes
2 answers

Adjacency Matrix from Java to SQL

I have a String data type adjacency matrix in Java: String[][] A; I want to read my adjacency matrix A into a MySQL table. The problem is I never know how many rows/columns I will need (nor would I want to create all the columns either). I think…
CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216
0
votes
2 answers

Decompose a tree into forest

How can I decompose a tree into forest such that each tree contains even number of vertices? Does i need to decompose tree randomly and check for every forest? I have already created adjacency matrix but doesn't helping me anyhow! What should be the…
ravi
  • 6,140
  • 18
  • 77
  • 154
0
votes
3 answers

Extra edge in my list?

I'm writing code to create a matrix out of a list of edges. However, when I run said code, I get a "phantom edge" that is not in the input data, which goes on to screw up the rest of my program. The edge is 9,2 in the matrix, or 8,1 in elemental…
ZAX
  • 968
  • 3
  • 21
  • 49
0
votes
3 answers

How to create adjacency list once a graph has been plotted?

I have an Edge class which stores: source (vertex), target (vertex) and weight. I have a Vertex class which stores: name, x-coordinates, y-coordinates, and Edge[] adjacentList. I also have a Graph class which stores two ArrayLists: edges and…
0
votes
1 answer

graph & tree representation

Can anyone tell me how to represent graph using vector through adjacency matrix & list . Also how to represent tree in c & c++ . How to represent graph using adjacency matrix & list in C .
MD MAHBUB ALAM
  • 57
  • 2
  • 3
  • 9
0
votes
2 answers

Vertex representation of a weighted unidirectional graph

I am using adjacency matrix to represent all the vertex of my weighted unidirectional large graph. In this graph no edge connects a vertex to itself. This makes all the diagonal elements of my adjacency matrix null. As my graph is large so in…
ravi
  • 6,140
  • 18
  • 77
  • 154
-1
votes
1 answer

How to stop Igraph generating duplicate vertices from adjacency matrix?

I am attemping to create a weighted social network between a series of characters. I have manually created an adjacency matrix with weighted values: . This has been linked to a separate file, in which attributes of the characters have been stored…
-1
votes
1 answer

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> list = new ArrayList<>(); public static ArrayList> incidentEdges(int v) { for(int i = 0; i < a.length; i++) { for(int j = 0; j <…
-1
votes
1 answer

how can I pass some nodes as init in sklearn.kmeans(n_clusters,init,....) in python

how can I pass 2 nodes as centroids to sklearn.kmeans(n_clusters,init,....) instead of random or kmeans++? algorithms['kmeans'] = KMeans(n_clusters=k_clusters,init='random', n_init=200)
-1
votes
1 answer

How is the Warshall algorithm different from Floyd algorithm in python?

I have school assigment to do both of them using adjacency matrix, but almost every google search only shows the floyd-warshall as one algorithm. I already have the code for only the floyd. Does someone know the Warshall-algorithm and what is the…
Natta
  • 3
  • 1
-1
votes
1 answer

Perl power of the adjacency matrix

Does anyone know how they would find the n-th power of the adjacency matrix? Here is the matrix I am trying to write the code for 0 0 1 0 0 0 1 0 1 1 0 1 …
Johnny
  • 17
  • 2
-1
votes
2 answers

survey data into network

I have a data frame that looks similar to…
Erdne Htábrob
  • 819
  • 11
  • 29
-1
votes
1 answer

Input NxN matrix by the user

I'm trying to convert my inputted data from g.addEdge(0, 1, 7) g.addEdge(1, 2, 9) g.addEdge(2, 0,14) into g.graph = [ [ 0, 7, 0], [ 0, 0, 9], [ 14, 0, 0,], ] simply, the first and second number as the…
ZawKey
  • 3
  • 3
-1
votes
1 answer

Adjacency matrix from text file containing nodes and connections python

I have a file which contains the edges for the matrix. For example, location (1, 2) in the adjacency matrix generated from the file is 2, as the pair 1 2 occurs twice in the graph. I need to make a adjacency matrix from this using python and I am…