function [Jammer,restnode]=intlintest(adj_matrix,k) u = adj_matrix; n = length(adj_matrix); f = sum(u); % 因为是对称矩阵,行和列和相同,所以无需两个都考虑; %f = sum(u)+sum(u'); f = f'; A = -ones(1,n); % Ax <= b (Ax 表示剩下节点的度之和); 目标函数为求剩下节点度和最小; b = -(n-k); % resnodenum >= k; lb = zeros(n,1); ub = ones(n,1); intcon=[1:n]; tic [x fval]= intlinprog(f,intcon,A,b,[],[],lb,ub) ; toc Jammernum = length(find(x==0)); Jammer = zeros(Jammernum,1); Jammer = find(x==0); restnode = zeros(n-Jammernum,1); restnode = find(x==1); Jammer = Jammer'; restnode = restnode'; end
adj_matrxi是邻接矩阵,k是干扰源个数。