addpathx('./shpaths');

% Sparse adjacency matrix of the network (may be non-symmetric)
adj = sparse([
	0	0	1	2	0	0	0;
	0	0	2	0	0	3	0;
	1	2	0	1	3	0	0;
	2	0	1	0	0	0	1;
	0	0	3	0	0	2	0;
	0	3	0	0	2	0	1;
	0	0	0	1	0	1	0;
]);
n = size(adj, 1);

% Notice that solvers work with transposed adjacency matrices,
% so that the sparse matrix can be efficiently traversed along
% columns (along the edges).
adjT = adj';

% SSSP
fprintf('* Looking for the shortest paths from node 1.\n');
src = 1;
d1 = fast_dijkstra(adjT, src)'
d2 = radix_dijkstra(adjT, src)'
d3 = spq_dijkstra(adjT, src)'

% MSSP
fprintf('* Solving all-to-all shortest path problem.\n');
D1 = mssp(1 : n, 1 : n, adjT, @fast_dijkstra)
D2 = mssp(1 : n, 1 : n, adjT, @radix_dijkstra)
D3 = mssp(1 : n, 1 : n, adjT, @spq_dijkstra)
% P.S. Use mssp with care; sometimes it requires the transposed adjmat;
%	   and sometimes it requires the original -- that is based on whether
%      the number of sources is larger than the number of destinations
%      (and that is in addition to the fact that the underlying SSSP solver
%      can accept either the original or the transposed adjmat.




