如何在Matlab中绘制连通性/邻接矩阵? [英] How to graph a connectivity/adjacency matrix in Matlab?

查看:475
本文介绍了如何在Matlab中绘制连通性/邻接矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MATLAB中绘制一个网络(一个电网)的结构。我有一个列表,其中包含每个分支的to-from节点。我没有节点的坐标,并且系统拓扑结构会随着每次模拟而改变。我还需要为不同的线/节点分配不同的颜色,以显现电压问题或过载等,类似于我使用biograph(代码如下)。



BIOGRAPH功能几乎完美。缺点是线条始终走出祖先块的底部,并进入后裔的顶部。作为祖先始终显示在其后代之上,图表有时非常混乱(对于大型系统)。

我试图将传记的属性'LayoutType'从默认'等级'更改为'radial'和'均衡',但这会给结果带来更糟的结果。



我在问什么?它不需要是一个完美的解决方案,任何改进都会很好。



这是我现在使用的代码:

  %%绘图biograph 
Sys =稀疏(from,to,1,s,s);

SysTri = tril(Sys + Sys');
bg = biograph(SysTri,[],'ShowArrows','off','ShowWeights','off');
h = view(bg);

%%颜色故障线:
set(h.nodes(newFaultNodes),'Color',[1 0.4 0.4]);
fowEdges = getedgesbynodeid(h,get(h.Nodes(newFaultNodes),'ID'));
revEdges = getedgesbynodeid(h,get(h.Nodes(fliplr(newFaultNodes)),'ID'));
edges = [fowEdges; revEdges];
set(边缘,'LineColor',[1 0 0])
set(边缘,'LineWidth',2)


解决方案

试试 matlab- BGL 。它链接到Boost Graph库并包含一些有用的布局算法。然后,您可以使用 gplot 进行可视化。

  gplot(A,fruchterman_reingold_force_directed_layout (一个)); 


I want to graph the structure of a network (a power grid) in MATLAB. I have a list containing to-from nodes for each branch. I don't have coordinates for the nodes, and the system topology changes for every simulation.

I also need to be able to assign different colors to various lines / nodes, to visualize voltage issues or overloads etc, similar to what I've done using biograph (code below).

The BIOGRAPH function is almost perfect. The drawback is that the lines always go out the "bottom" of the ancestor block, and into the "top" of the descendant. As an ancestor is always displayed above its descendants, the graphs are sometimes very chaotic (for large systems).

I have tried changing the property 'LayoutType' of the biograph from the default 'hierarchical' to both 'radial' and 'equilibrium', but this gives even worse results.

Is what I'm asking possible? It doesn't need to be a perfect solution, any improvements would be great.

This is the code I use now:

%% Plot biograph
Sys = sparse(from,to,1,s,s);  

SysTri = tril(Sys + Sys'); 
bg = biograph(SysTri,[],'ShowArrows','off','ShowWeights','off');
h = view(bg);  

 %% Color faulted line:
set(h.nodes(newFaultNodes),'Color',[1 0.4 0.4]);
fowEdges = getedgesbynodeid(h,get(h.Nodes(newFaultNodes),'ID'));
revEdges = getedgesbynodeid(h,get(h.Nodes(fliplr(newFaultNodes)),'ID'));
edges = [fowEdges;revEdges];
set(edges,'LineColor',[1 0 0])
set(edges,'LineWidth',2)

解决方案

Try out matlab-bgl. It links to the Boost Graph library and includes a few useful layout algorithms. You can then use gplot to visualize.

gplot(A, fruchterman_reingold_force_directed_layout(A));

这篇关于如何在Matlab中绘制连通性/邻接矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆