📄 fm_mintree.m
字号:
function [pmuloc, pmunum] = fm_mintree(zeroinj, hdl_pmu,hdl_nob)% FM_MINTREE compute minimum spanning tree of the current network% (for PMU placement routines)%% (...) = FM_MINTREE(...)%% This function is generally called by FM_PMULOC%%Author: Federico Milano%Date: 11-Nov-2002%Version: 1.0.0%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.global Bus Line Fig Settingsif Settings.octave A = zeros(Bus.n,Bus.n); pmuloc = zeros(Bus.n,Bus.n);else A = sparse(Bus.n,Bus.n); pmuloc = sparse(Bus.n,Bus.n);endfor i = 1:Bus.n nonzero = find(Line.Y(i,:)); A(i,nonzero) = ones(1,length(nonzero));endif Settings.octave r = 1:Bus.n;else p = symrcm(A); r(p) = 1:Bus.n; A = A(p,p);endspanning = zeros(Bus.n,1);pmunum = zeros(Bus.n,1);for i = 1:Bus.n spanning = A(i,:); pmuloc(i,i) = 1; pmunum(i) = 1; sumspan = sum(spanning); while sumspan < Bus.n for j = 1:Bus.n B(j) = sum(full(spanning | A(j,:))); end [value, indice] = max(B); spanning = spanning | A(indice,:); pmunum(i) = pmunum(i) + 1; pmuloc(i,indice) = 1; sumspan = sum(spanning); if Fig.pmu set(hdl_pmu,'String',int2str(pmunum(i))); set(hdl_nob,'String',int2str(Bus.n-sumspan)); drawnow end endendpmuloc = pmuloc(r,r);pmunum = pmunum(r);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -