%% Adjacency Matrix of Weighted Graph
% Create an undirected graph using an upper triangular adjacency matrix. When constructing a graph with an adjacency matrix, the nonzero values in the matrix correspond to edge weights.

A = [0 5 3 0;0 0 1 2; 0 0 0 11; 0 0 0 0]

%

G = graph(A,'upper')

%

G.Edges

%
% Use adjacency to return the adjacency matrix of the graph. Regardless of the form of adjacency matrix used to construct the graph, the adjacency function always returns a symmetric and sparse adjacency matrix containing only 1s and 0s.

B = adjacency(G)

% Copyright 2015 The MathWorks, Inc.