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 Jul 20, 2022
1 parent 8036a4f commit b2006f9
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
9 changes: 5 additions & 4 deletions harmonicnobelity.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function hc = harmonicnobelity(G,select,s)
%nc = nobelity(G,select)
%hc = nobelity(G,select,s)
%G is a graph, directed or no
%select is a vector of zeros and ones
%s is an optional string, in for incloseness, out for outcloseness
%nc is the average distance to all nodes in select
%if select is a vector of ones, nc is the harmonic centrality measure
%(=default)
%hc is the average distance to all nodes in select
%if select is a vector of ones, hc is the harmonic centrality measure
%
%21 February 2018, Richard S.J. Tol
%22 March 2022, Richard S.J. Tol

n = size(G.Nodes,1);
dist = distances(G);
Expand Down
26 changes: 26 additions & 0 deletions holdercentrality.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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
%s is an optional string, in for incloseness, out for outcloseness
%
%21 February 2018, Richard S.J. Tol

n = size(G.Nodes,1);
dist = distances(G);
invdist = dist.^h;
for i=1:n
invdist(i,i)=0;
end

if ~exist('s')
hc = (n-1)*sum(invdist,2).^(-1/h);
elseif s(1)=='o'
hc = (n-1)*sum(invdist,2).^(-1/h);
elseif s(1)=='i'
hc = (n-1)*(sum(invdist,1)').^(-1/h);
else
hc = 0;
end

end
37 changes: 37 additions & 0 deletions holdernobelity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function hc = holdernobelity(G,select,h,s)
%hc = nobelity(G,select,s)
%G is a graph, directed or no
%select is a vector of zeros and ones
%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

n = size(G.Nodes,1);
dist = distances(G);
for i=1:n
if select(i)==0
if ~exist('s')
dist(:,i) = inf;
elseif s(1)=='o'
dist(:,i) = inf;
else
dist(i,:) = inf;
end
end
end
invdist = dist.^h;
for i=1:n
invdist(i,i)=0;
end
if ~exist('s')
hc = (n-1)*sum(invdist,2).^(-1/h);
elseif s(1)=='o'
hc = (n-1)*sum(invdist,2).^(-1/h);
elseif s(1)=='i'
hc = (n-1)*(sum(invdist,1)').^(-1/h);
else
hc = 0;
end

0 comments on commit b2006f9

Please sign in to comment.