%% Page Rank of 6 Websites
% Create and plot a graph containing six fictitious websites.

s = [1 1 2 2 3 3 3 4 5];
t = [2 5 3 4 4 5 6 1 1];
names = {'http://www.example.com/alpha', 'http://www.example.com/beta', ...
         'http://www.example.com/gamma', 'http://www.example.com/delta', ...
         'http://www.example.com/epsilon', 'http://www.example.com/zeta'};
G = digraph(s,t,[],names);
plot(G,'NodeLabel',{'alpha','beta','gamma','delta','epsilon','zeta'})

%
% Calculate the page rank of each website using the centrality function. Append this information to the Nodes table of the graph as an attribute of the graph nodes.

pg_ranks = centrality(G,'pagerank')

%

G.Nodes.PageRank = pg_ranks;
G.Nodes

%
% Also determine which nodes are hubs and authorities using centrality and append the scores to the Nodes table.

hub_ranks = centrality(G,'hubs');
auth_ranks = centrality(G,'authorities');
G.Nodes.Hubs = hub_ranks;
G.Nodes.Authorities = auth_ranks;

%

G.Nodes

% Copyright 2012 The MathWorks, Inc.