Is this an Adjacency list ?

1 vue (au cours des 30 derniers jours)
vignesh raju
vignesh raju le 13 Fév 2016
Commenté : Walter Roberson le 21 Fév 2016
I converted a .gml file to adjacency list and got the following output. Is this how an adjacency list of 7x1 cell look?
li =
[1x2 double]
[1x2 double]
[1x2 double]
[1x2 double]
[1x2 double]
[1x2 double]
[1x2 double]

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Fév 2016
It could. But it probably doesn't.
You could use cell2mat(li) which would output a 7 x 2 numeric array.
I suspect that our li is a list of node number pairs, as opposed to an adjacency matrix. If so then,
li_m = mat2cell(li);
numnodes = max(li_m(:));
adj = sparse(li_m(:,1), li_m(:,2), 1, numnodes, numnodes);
  3 commentaires
vignesh raju
vignesh raju le 21 Fév 2016
Solved that by using it directly as an array and not as a cell array.
Walter Roberson
Walter Roberson le 21 Fév 2016
Sorry,
li_m = mat2cell(li);
should have been
li_m = cell2mat(li);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by