📄 seek_sixcycle.m
字号:
function [cycle_position_all find_six]=seek_sixcycle(H,p)
%clc;clear all;
% H=[1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0;
% 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0;
% 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0;
% 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0;
% 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1;
% 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0;
% 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1;
% 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0;
% 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0;
% 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0;
% 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1;
% 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 0;
% 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0;
% 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0;
% 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0];
% dv=3;
% dc=9;
% p=12;
% S = [0 0 0 0 0 0 0 0 0;
% 0 5 2 6 11 1 8 10 7;
% 0 6 4 1 9 5 2 7 3];
% H=hcreat(H_origin,p,S)
[m,n]=size(H);
%S=[0 0 0 0;0 4 1 2;0 2 3 1];
cycle_position_all=[];find_six=0;
for l=1:m-p
l;
h_r=H(l,:);
r_index=find(h_r);
L_r=length(r_index);
for i=1:L_r-1
i;
for j=i+1:L_r
j;
h_c=H(l+1:end,r_index(j));%取出第一行中第二个1所在的列,不包括本身
c_index=find(h_c);
c_index=c_index+l;
L_c=length(c_index);
for k=1:L_c
h_r_two=H(c_index(k),:);%取出上述列中各个1所在的行作为第二行
r_index_two=find(h_r_two);
L_r_two=length(r_index_two);
for i2=1:L_r_two
if r_index_two(i2)~=r_index(j)&&r_index_two(i2)~=r_index(i)%如果第二行中1所在的列不等于第二个1所在的列
h_c_two=H(l+1:end,r_index_two(i2));%取出第二行中1所在的列
c_index_two=find(h_c_two);
c_index_two=c_index_two+l;
L_c_two=length(c_index_two);
for j2=1:L_c_two
if c_index_two(j2)~=c_index(k)&&H(c_index_two(j2),r_index(i))==1
cycle_position=[l r_index(i);l r_index(j);c_index(k) r_index(j);c_index(k) r_index_two(i2);c_index_two(j2) r_index_two(i2);c_index_two(j2) r_index(i)];
cycle_position_all=[cycle_position_all cycle_position];
find_six=find_six+1;
end
end
end
end
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -