Hello guys, I hope you are doing fine.
I would like to take a matrix and create a Tuple, where the first element is the row number (an index) and the second element is the row (a vector).
graph =[0 2 4 0 0 0; 0 0 1 7 0 0; 0 0 0 0 3 0;
0 0 0 0 0 1; 0 0 0 2 0 5; 0 0 0 0 0 0];
I would like to get a tuple in the following way:
6-element Tuple
(1,[0 2 4 0 0 0])
(2,[0 0 1 7 0 0])
(3,[0 0 0 0 3 0])
(4,[0 0 0 0 0 1])
(5,[0 0 0 2 0 5])
(6,[0 0 0 0 0 0])
With a vector it is easy because
f=collect(enumerate(graph[1,:]))
returns an f=
(1,0)
(2,2)
(3,4)
(4,0)
(5,0)
(6,0)
How can I create a Tuple with the rows of the Matrix as second element? Any thoughts?
Thanks in advance.