is it a correct output of adjacency matrice?
    2 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi
I have a list of edges, and nodes. could you please let me know is it a correct method to show the adjancy matrice? I have attached the csv files accordingly as well.
nodes_info = readtable('nodelist.csv');
edges_info = readtable('edgelist.csv');
G = graph();
G = G.addnode(string(nodes_info.Id));
G = G.addedge(string(edges_info.Source), string(edges_info.Target));
A = adjacency(G,'weighted');
figure
spy(A)

0 Commenti
Risposte (1)
  Piyush Patil
 il 6 Ott 2023
        Hello Hasan,
As per my understanding, you have created an adjacency matrix by using the data present in "edgelist.csv" and "nodelist.csv" file and you want to know if this is the correct way to create an adjacency matrix.
By looking at the "edgelist.csv" file, it seems that you are having the data for directed graph whereas "graph" function in MATLAB is used for undirected graphs.
Although, rest of your code is correct, I would suggest you use digraph function instead of "graph" function. "digraph" function is used in case of directed graphs.
Please replace line number 3 of ypur code which is - 
G = graph();
with line
G = digraph();
Rest of the code is correct.
I hope this resolves the issue you were having.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Graph and Network Algorithms in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!