All the possible path between two points without repetition
Show older comments
I'm looking to get the value of all pairwise data between two points by an iteration. The iteration contains direct and indirect paths. For example if there are 3 points, and having all the pairwise scores between points being available:
a_11 = 0; a_12 = 0.2; a_13 = 0.6; a_32 = -0.3; % a_23 = -a_32 (same for all other scores)
Now if the value for example, the path between 1-2 is considered, we would have (direct + indirect):
a_12_iter1 = a_12 + (a_13 + a_32)% initial paiwsie scores between all points are known, a_12_iter1 means the first iteration
%considering the initial pairwise scores.
a_12_iter1 = 0.2 + (0.6 - 0.3) = 0.5
No path is chosen twice.
Another example is having 4 points (square):

a_12_iter1 = a_12 + (a_14 + a_43 + a_32 + a_13);
a_13_iter1 = a_13 + (a_12 + a_23 + a_14 + a_43 + a_24); %same procedure is used for all other values (a_14, a_24, ...)
The data gets large fast, another instant is a pentagon (5 points):

a_13_iter1 = a_13 + (a_12 + a_23 + a_15 + a_54 + a_43 + a_43 + a_25 + a_53 + a_14)% no path is chosen twice
I am looking for a code that can perform this operation if my original data is large (100 points). The code for 3 points is given as:
Does anyone know how I can write this code? Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Resizing and Reshaping Matrices 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!