create adjacency matrix of non-integer values

1 view (last 30 days)
Hello
I have a fuzzy edge list that I want to convert it to adjacency matrix. I tried using sparse matrix from this thread in stackoverflow. But I get error. This is a part of my edge list.
A B Value
0 3539 9.22
0 6281 7.24
0 13033 7.55
0 19654 9.14
0 36825 8.84
0 63309 8.26
1 12855 9.42
1 22542 8.10
1 66857 8.77
1 72969 9.58
1 7281 4.88
1 33392 4.62
1 33393 3.46
1 33394 3.22
1 59140 2.37
1 75011 4.77
2 12717 7.81
4 14870 8.95
....
How can I create adjacency from this?
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 21 Jan 2016
Are A and B intended to be node numbers, with the lowest one numbered 0? MATLAB does not permit 0 to be used as an index so you would need to add one to A and B to construct the sparse matrix.
adjacency = sparse(A+1, B+1, Value)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!