How to apply netting in Adjacency matrix

1 view (last 30 days)
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.

Accepted Answer

Steven Lord
Steven Lord on 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 Comments
Steven Lord
Steven Lord on 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')
FoxK
FoxK on 15 Nov 2019
Thanks Steve Works Perfectly

Sign in to comment.

More Answers (0)

Categories

Find more on Graph and Network Algorithms 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!