%% Custom Graph Node Coordinates
% Create a weighted graph.

s = [1 1 1 1 1 2 2 7 7 9 3 3 1 4 10 8 4 5 6 8];
t = [2 3 4 5 7 6 7 5 9 6 6 10 10 10 11 11 8 8 11 9];
weights = [1 1 1 1 3 3 2 4 1 6 2 8 8 9 3 2 10 12 15 16];
G = graph(s,t,weights)

%
% Plot the graph using custom coordinates for the nodes. The x-coordinates are specified using XData, the y-coordinates are specified using YData, and the z-coordinates are specified using ZData. Use EdgeLabel to label the edges using the edge weights.

x = [0 0.5 -0.5 -0.5 0.5 0 1.5 0 2 -1.5 -2];
y = [0 0.5 0.5 -0.5 -0.5 2 0 -2 0 0 0];
z = [5 3 3 3 3 0 1 0 0 1 0];
plot(G,'XData',x,'YData',y,'ZData',z,'EdgeLabel',G.Edges.Weight)

%
% View the graph from above.

view(2)

% Copyright 2012 The MathWorks, Inc.