2

我想在 MATLAB 中绘制网络(电网)的结构。我有一个包含每个分支的 to-from 节点的列表。我没有节点的坐标,并且每次模拟的系统拓扑都会发生变化。

我还需要能够为各种线/节点分配不同的颜色,以可视化电压问题或过载等,类似于我使用传记所做的(下面的代码)。

BIOGRAPH 功能几乎是完美的。缺点是行总是从祖先块的“底部”出来,进入后代块的“顶部”。由于祖先总是显示在其后代之上,因此图表有时非常混乱(对于大型系统)。

我尝试将传记的属性“LayoutType”从默认的“分层”更改为“径向”和“平衡”,但这会产生更糟糕的结果。

我问的可能吗?它不需要是一个完美的解决方案,任何改进都会很棒。

这是我现在使用的代码:

%% 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)
4

1 回答 1

0

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));
于 2014-08-05T15:55:24.037 回答