Is this an Adjacency list ?
1 view (last 30 days)
Show older comments
vignesh raju
on 13 Feb 2016
Commented: Walter Roberson
on 21 Feb 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]
0 Comments
Accepted Answer
Walter Roberson
on 13 Feb 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 Comments
Walter Roberson
on 21 Feb 2016
Sorry,
li_m = mat2cell(li);
should have been
li_m = cell2mat(li);
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!