Question #6731   Submitted by Answiki on 09/25/2022 at 09:05:45 AM UTC

How to visualize an undirected graph from its adjacency matrix with Matlab?

Answer   Submitted by Answiki on 09/25/2022 at 09:00:24 AM UTC

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:

4 events in history
Question by Answiki 09/25/2022 at 09:10:27 AM
How to plot undirected graph with Matlab?
Question by Answiki 09/25/2022 at 09:05:45 AM
How to visualize an undirected graph from its adjacency matrix with Matlab?
Answer by Answiki on 09/25/2022 at 09:00:24 AM

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:

Question by Answiki 09/25/2022 at 08:57:58 AM
How to draw undirected graph from adjacency matrix with Matlab?
# ID Query URL Count

Icons proudly provided by Friconix.