trying to calculate the returnability of a network after every iteration

조회 수: 1 (최근 30일)
Nicolle Small
Nicolle Small 2021년 4월 6일
답변: Zinea 2024년 2월 23일
i have a network which i am doing multiple calculations for. however the main one is the returnabilty using ths formula,
returnability = (trace(expm(AT))-n)/(trace(expm(A))-n);
however with my network, i have removed every edge and added them back randomly using this coding,
AT = triu(A);
m = numedges(G);
n = numnodes(G);
[i,j]=find(AT);
p = randperm(m);
for k = 1:m
I = j(p(k));
J = i(p(k));
AT(I,J) = 1;
end
where A is the adjacency matrix for the network.
The main thing i am struggling with is after each iteration of an edge being added i want to calculate the returnability. i know i will need a loop but i am not sure how to code it up.
any help/advice would be appreciated a lot.

답변 (1개)

Zinea
Zinea 2024년 2월 23일
You want to calculate the returnability using the given formula after each iteration of edge addition to the graph. For this, you need to incorporate 2 specific changes in your code:
1. Initialize a vector to store returnability values for each iteration. Add this line at the before the start of the loop.
returnability_values = zeros(m, 1);
2. Calculate the returnability for this iteration. Add this line just before the ‘end’ statement.
returnability = (trace(expm(AT)) - n) / (trace(expm(A)) - n);
returnability_values(edge_index) = returnability;
The vector ‘returnabillity_valuescontains the returnability after each iteration.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by