How to graph adjacency matrix using MATLAB

前端 未结 3 1411
暖寄归人
暖寄归人 2021-01-05 01:25

I want to create a plot showing connections between nodes from an adjacency matrix like the one below.

\"enter

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 01:53

    As of R2015b, MATLAB now has a suite of graph and network algorithms. For this example, you can create an undirected graph object and then plot it using the overloaded plot function:

    % Create symmetric adjacency matrix
    A = [1 1 0 0 1 0;
         1 0 1 0 1 0;
         0 1 0 1 0 0;
         0 0 1 0 1 1;
         1 1 0 1 0 0;
         0 0 0 1 0 0];
    % Create undirected graph object
    G = graph(A);
    % Plot
    plot(G);
    

提交回复
热议问题