How to visualize an undirected graph from its adjacency matrix with Matlab?
The graph()
Matlab function creates an undirected graphs object (edges connecting the nodes). The following example plot an undirected graph from the adjacency matrix :
% Adjacency matrix
A = [ 0 1 1 1 ;
1 1 0 0 ;
1 0 1 1 ;
1 0 1 0 ];
% Create undirected graph object
G = graph(A);
% Plot graph
p=plot(G, 'MarkerSize', 10);
Note that the adjacency matrix must be symmetrical. The above code displays the following figure:
The graph()
Matlab function creates an undirected graphs object (edges connecting the nodes). The following example plot an undirected graph from the adjacency matrix :
% Adjacency matrix
A = [ 0 1 1 1 ;
1 1 0 0 ;
1 0 1 1 ;
1 0 1 0 ];
% Create undirected graph object
G = graph(A);
% Plot graph
p=plot(G, 'MarkerSize', 10);
Note that the adjacency matrix must be symmetrical. The above code displays the following figure:
# | ID | Query | URL | Count |
---|