MATLAB - uppgifter i kombinatorik
Hej.
Jag vet inte om det är rätt ställe att fråga detta, men jag har två uppsättningar uppgifter i MATLAB att lösa. Hoppas någon kan hjälpa mig. Detta är första uppsättningen av problem, tror jag har lyckats med det första steget:
Write a function valency(A) that takes an adjacency matrix and gives a list of the valency of each vertex.
Write a function walksexact(A, k) that takes an adjaceny matrix A and a distance k and computes a matrix containing the number of walks from vi to vj in exactly k steps.
Use walksexact to write a function walksmax(A, k) that computes the number of walks in at most k steps.
Write a function eccentricities(A) that takes an adjacency matrix and computes a list of ecc(v) for all vertices.
Write the functions radius(A) and diameter(A) which compute the radius and the diameter of the graph with adjacency matris A. It helps to use the function eccentricities.
Write a function closedwalks(A, k) that takes an adjacency matrix and computes the number of closed walks of length k in the corresponding graph.
Write a function connected(A) that returns one if the corresponding graph is connected, and zero otherwise.
Det första, valency(A), har jag skrivit såhär:
function v = valency(A);
B = transpose(A);
v = sum(B);
end
Jag vet dock inte om det är rätt, själv tycker jag att det ser rätt ut när jag testar. Jag är riktig nybörjare på detta med MATLAB så all hjälp jag kan få är jag glad för!