Problem 45261. List every vertices neighbor indices
- a vertex is the neighbor of another if they are linked with an edge in at least one same triangle. A vertex is not neighbor of itself.
- Output N row order is crucial since row number actually corresponds to the vertex id / index.
- Output N cells content order doesn't matter, but it doesn't admit any duplicated index / value.
Solution Stats
Problem Comments
-
4 Comments
Pedagogic solution is available in position 2 (commented, same as solution 1 but more explicit thus suboptimal).
In problem 45261, my solution produces a cell array with the correct contents except that my vectors are columns not rows as required in the solution tests. How do I change the contents of each cell from a column to row vector?
Hi Lloyd, I am sorry I discover your comment only now. Maybe use rowfiun instead of cellfun. Else, just transpose your column vector inside its cell.
@Lloyd cellfun(@transpose, ca, UniformOutput = false) when ca is your cell array, but as you've already found the best choice is often to construct ca such that this step is not even necessary.
Solution Comments
Show commentsProblem Recent Solvers24
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6502 Solvers
-
Find the maximum number of decimal places in a set of numbers
3145 Solvers
-
Concatenate string with cell array of strings
63 Solvers
-
2833 Solvers
-
Convert from Fahrenheit to Celsius
26314 Solvers
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!