-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function cc = crosscloseness(G,select,d,h) | ||
%function cc = crosscloseness(G,select,d,h) | ||
% | ||
%cc is the generalized average crosscloseness of nodes in a graph | ||
%G is a graph | ||
%select is a vector of zeros and ones | ||
%d sets the depth of the horizoGal relation | ||
% d = 1 siblings | ||
% d = 2 first cousins | ||
% d = 3 second cousins | ||
%h is the power of the generalized average | ||
% h = 1 arithmetic average | ||
% h = 0 geometric average | ||
% h = -1 harmonic average | ||
% | ||
%23 August 2022, Richard S.J. Tol | ||
|
||
crossdist = crossdistance(G,select,d); | ||
|
||
cc = sum(crossdist.^h,1)/sum(select); | ||
cc = cc.^(1/h); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function cd = crossdistance(G,select,d) | ||
%function cd = crossdistance(G,select,d) | ||
% | ||
%cd is the matrix of horizontal distances between selected nodes of G | ||
%G is a graph | ||
%select is a vector of zeros and ones | ||
%d sets the depth of the horizoGal relation | ||
% d = 1 siblings | ||
% d = 2 first cousins | ||
% d = 3 second cousins | ||
% | ||
%23 August 2022, Richard S.J. Tol | ||
|
||
in = indegree(G); | ||
nn = size(G.Nodes,1); | ||
cd = zeros(nn,nn); | ||
for i=1:nn-1, | ||
if in(i) > 0 | ||
for j=i+1:nn, | ||
if select(i) == 1 | select(j) == 1, | ||
cd(i,j) = horzdist(G,G.Nodes{i,:},G.Nodes{j,:},d); | ||
end | ||
end | ||
end | ||
end | ||
cd = cd + cd'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters