How to apply netting in Adjacency matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a weighted Adjacency matrix 138 x 138 representing interbank exposure. A link ij in the matrix represents loans originating from bank i to bank j. I would like to have a netted bilateral exposure such that if two banks lend to one another, for instance, a bank A(i) lends to bank B(j) and B(i) has also lent to A(j). I intend to compare the two loans and subtract the loans and assign the difference to a bank that had the highest value while deleting the link for a bank with the lowest values(assign zero) in the matrix. Any help on how to represent this in a Matlab code will be appreciated.
0 commentaires
Réponse acceptée
Steven Lord
le 15 Nov 2019
This sounds like it might be a homework assignment, so I'm only going to give a hint. The transpose operator .' may be of interest to you.
Once you have your modified adjacency matrix, if you want to perform further analysis on it you may want to use it to create a digraph as that will let you easily visualize the network (calling plot on the digraph) and determine node successors, shortest paths, etc.
3 commentaires
Steven Lord
le 15 Nov 2019
Let's look at a small example. In this example bank 1 owes bank 2 $8 and bank 2 owes bank 1 $3 (where $ would probably represent a million dollars, but I just wanted to work with small numbers.)
>> rng default
>> A = reshape(randperm(9), [3 3])
>> A = A - diag(diag(A))
A =
0 8 2
3 0 4
7 1 0
Would this be your desired result?
>> M = max(A-A.', 0)
M =
0 5 0
0 0 3
5 0 0
Let's plot the digraph of bank relationships, with the amount owed as the edge labels.
plot(digraph(M), 'EdgeLabelMode', 'auto')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!