Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rtol authored Aug 23, 2022
1 parent 5b97e79 commit e8fd11a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 13 deletions.
21 changes: 21 additions & 0 deletions crosscloseness.m
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);
26 changes: 26 additions & 0 deletions crossdistance.m
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';
6 changes: 4 additions & 2 deletions harmoniccentrality.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function hc = harmoniccentrality(G,s)
%hc = harmoniccentrality(G,s)
%G is a graph, directed or no
%select is a vector of zeros and ones
%
%hc is the harmonic average proximity of all nodes to all nodes in G
%G is a graph
%s is an optional string, in for incloseness, out for outcloseness
%(=default)
%
%21 February 2018, Richard S.J. Tol

Expand Down
7 changes: 4 additions & 3 deletions harmonicnobelity.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function hc = harmonicnobelity(G,select,s)
%hc = nobelity(G,select,s)
%G is a graph, directed or no
%
%hc is the harmonic average proximity of all nodes to selected nodes in G
%G is a graph
%select is a vector of zeros and ones
%if select is a vector of ones, hc is the harmonic centrality measure
%s is an optional string, in for incloseness, out for outcloseness
%(=default)
%hc is the average distance to all nodes in select
%if select is a vector of ones, hc is the harmonic centrality measure
%
%22 March 2022, Richard S.J. Tol

Expand Down
13 changes: 10 additions & 3 deletions holdercentrality.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
function hc = holdercentrality(G,h,s)
%hc = holdercentrality(G,h,s)
%G is a graph, directed or no
%select is a vector of zeros and ones
%
%hc is the generalized average proximity of all nodes to all nodes in G
%G is a graph
%h is power of the generalized average
% h=1 arithmetic average
% h=0 geometric average
% h=-1 harmonic average
%note that hc is undefined for a unconnnected graph unless h<0
%s is an optional string, in for incloseness, out for outcloseness
%(=default)
%
%21 February 2018, Richard S.J. Tol
%23 August 2022, Richard S.J. Tol

n = size(G.Nodes,1);
dist = distances(G);
Expand Down
15 changes: 10 additions & 5 deletions holdernobelity.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
function hc = holdernobelity(G,select,h,s)
%hc = nobelity(G,select,s)
%G is a graph, directed or no
%hc = holdernobelity(G,select,s)
%
%hc is the generalized average proximity of all nodes to selected nodes in G
%G is a graph
%select is a vector of zeros and ones
%h is power of the generalized average
% h=1 arithmetic average
% h=0 geometric average
% h=-1 harmonic average
%note that hc is undefined for a unconnnected graph unless h<0
%s is an optional string, in for incloseness, out for outcloseness
%(=default)
%hc is the average distance to all nodes in select
%if select is a vector of ones, hc is the harmonic centrality measure
%
%22 March 2022, Richard S.J. Tol
%23 August 2022, Richard S.J. Tol

n = size(G.Nodes,1);
dist = distances(G);
Expand Down

0 comments on commit e8fd11a

Please sign in to comment.