How to apply netting in Adjacency matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2019-11-15
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 个评论
Steven Lord
2019-11-15
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!