91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .rar
    金幣: 2
    下載: 2 次
    發布日期: 2021-06-10
  • 語言: Matlab
  • 標簽: MCP??matlab??

資源簡介

無向圖中最大團問題的matlab代碼,利用的算法是回溯法,代碼包含MCP函數、測試代碼和根據鄰接矩陣畫無向圖的函數;

資源截圖

代碼片段和文件信息

function?graph1(relcontrol)

%由鄰接矩陣畫圖

%輸入為鄰接矩陣,必須為方陣;

%第二個輸入為控制量,0表示無向圖,1表示有向圖。默認值為0

r_size=size(rel);%獲取矩陣大小

if?nargin<2?%如果參數小于2,默認無向圖

????control=0;

end

if?r_size(1)~=r_size(2)

????disp(‘Wrong?Input!?The?input?must?be?a?square?matrix!‘);%輸入為鄰接矩陣,必須為方陣

????return;

end

len=r_size(2);

!echo?len;

disp(len);

?

rho=10;%限制圖尺寸的大小

r=1/1.05^len;%點的半徑

theta=0:(2*pi/len):2*pi*(1-1/len);%以0開始,步長2*pi/len,結束2*pi*(1-1/len),相當于有len個點

[pointxpointy]=pol2cart(theta‘rho);

theta=0:pi/36:2*pi;%73個點

!echo?theta:

disp(theta);

[tempxtempy]=pol2cart(theta‘r);%73個坐標

point=[pointxpointy];%6個坐標點

!echo?point;

disp(point);

hold?on

for?i=1:len

????temp=[tempxtempy]+[point(i1)*ones(length(tempx)1)point(i2)*ones(length(tempx)1)];%73行1列的1矩陣與point每個坐標相乘

????plot(temp(:1)temp(:2)‘r‘);%plot(xy)畫出圓圈

?????%plot(point(:1)point(:2)‘r‘);%plot(xy)

????text(point(i1)-0.3point(i2)num2str(i));

????%畫點

end

for?i=1:len

????for?j=1:len

????????if?rel(ij)%如果鄰接矩陣rel中該點是1,代表相連

????????????link_plot(point(i:)point(j:)rcontrol);

????????????%連接有關系的點

????????end

????end

end

set(gca‘XLim‘[-rho-rrho+r]‘YLim‘[-rho-rrho+r]);

axis?off

%%

function?link_plot(point1point2rcontrol)

%連接兩點

temp=point2-point1;

if?(~temp(1))&&(~temp(2))

????return;

????%不畫子回路;

end

theta=cart2pol(temp(1)temp(2));

[point1_xpoint1_y]=pol2cart(thetar);

point_1=[point1_xpoint1_y]+point1;

[point2_xpoint2_y]=pol2cart(theta+(2*(theta
point_2=[point2_xpoint2_y]+point2;

if?control

????arrow(point_1point_2);

else

????plot([point_1(1)point_2(1)][point_1(2)point_2(2)]);

end

%%

function?arrow(startstopl)

%startstop分別為起點和終點

%l為箭頭的線長度,默認為主線長的1/10

t=0.1;

ang=15/180*pi;

temp=stop(1)-start(1)+1i*(stop(2)-start(2));

L=abs(temp);P=angle(temp);

if?nargin<3

????l=t*L;

end

p1=P-ang;p2=P+ang;

a=[stop(1)-l*cos(p1)?stop(2)-l*sin(p1)];

b=[stop(1)-l*cos(p2)?stop(2)-l*sin(p2)];

hold?on

plot([start(1)?stop(1)][start(2)?stop(2)]);

plot([a(1)?stop(1)][a(2)?stop(2)]);

plot([b(1)?stop(1)][b(2)?stop(2)]);

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2422??2018-10-22?16:43??MCP_self\graph1.m

?????文件????????384??2018-10-22?18:39??MCP_self\main.m

?????文件???????1074??2018-10-22?16:33??MCP_self\MCP.m

?????目錄??????????0??2018-10-22?20:29??MCP_self

-----------?---------??----------?-----??----

?????????????????3880????????????????????4


評論

共有 條評論