• 大小: 3KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Matlab
  • 标签:   matla  

资源简介

自己写的一个寻找割集的matlab小程序,主要用来在生成树的过程中寻找割集

资源截图

代码片段和文件信息

function [ chord_link ] = find_cutset( netold_treereplacementref_tree )
%UNtitleD5 Summary of this function goes here
%   Detailed explanation goes here
%find the cutset of the replacement line in old tree
line_re_indx=ref_tree(replacement);
re_op_node=net(line_re_indx1);
re_ed_node=net(line_re_indx2);

%decode the old tree
m_old_tree=length(old_tree);

node_old_tree=zeros(m_old_tree2);

for i=1:m_old_tree
    node_old_tree(i1)=net(old_tree(i)1);
    node_old_tree(i2)=net(old_tree(i)2);
end

island_1=zeros(1m_old_tree*2);
island_2=zeros(1m_old_tree*2);

%search the first isolated island
island_indx=2;
search_target=re_op_node;
avoid_target=re_ed_node;
island_1(1)=search_target;
search_index=1;
search_tree=node_old_tree;
while search_target~=0 %this segment can be optimized
     for m_node_indx=1:m_old_tree
     if search_tree(m_node_indx1)==search_target && search_tree(m_node_indx2)~=avoid_target
        island_1(island_indx)=search_tree(m_node_indx2);
        island_indx=island_indx+1;
        search_tree(m_node_indx:)=0;
     elseif search_tree(m_node_indx2)==search_target && search_tree(m_node_indx1)~=avoid_target
        island_1(island_indx)=search_tree(m_node_indx1);
        island_indx=island_indx+1;
        search_tree(m_node_indx:)=0;
     end
     end
     search_index=search_index+1;
     search_target=island_1(search_index);
end

%search the second isolated island
%can also be optimized
island_indx=2;
search_index=1;
search_target=re_ed

评论

共有 条评论