Hi,
- To calculate the number of walks of exactly k steps, you just need to multiply the Adj matrix k times.
- Once you have the exwalk, you can define the maxwalk function as follows:
function W = maxwalk(Adj, k)
n = size(Adj, 1);
W = zeros(n);
for i = 1:k
W = W + exwalk(Adj, i);
end
end
3. For the eccentricity calculation, you can use the Floyd Warshall algorithm to find the shortest path between all the nodes and get the max distance for each.
function ecc = eccentricities(A)
% Compute the shortest path lengths using the Floyd-Warshall algorithm
D = floydWarshall(A);
ecc = max(D, [], 2);
end
You will need to define the floydWarshall function on your own.
Hope this helps!