mencari nilai minimum dari algoritma graph

1 次查看(过去 30 天)
I have a question about Graph Coloring, in my function to find the maximum value of a graph algorithm (which I list below), I want to ask how to find a minimum value in the graph coloring algorithm and the minimum value is not equal to zero but the minimum value more than one
function [derajat,derajatmax,dremax1,dremax,maxdegsir,outmagdegsir,m,n,idx_maxsir,taud]= alokasigraph(taud,sir)
derajat=sum(taud);
derajatmax=max(max(derajat));
dremax1=find(derajat==derajatmax);
dremax=dremax1(1,1);
maxdegsir=sir;
outmagdegsir=max(max(maxdegsir(:,dremax),[],'all'));
[m,n]=find(maxdegsir==outmagdegsir);
idx_maxsir=[m(1),n(1)];
maxdegsir(m(1),:)=0;
maxdegsir(:,n(1))=0;
taud(m(1),:)=0;
taud(:,n(1))=0;
end

回答(1 个)

Jaynik
Jaynik 2024-9-5
Based on the given function, to find the minimum value in a graph coloring algorithm where the minimum value is greater than one, you can modify your approach to focus on finding the smallest degree (number of edges connected to a vertex) that is greater than one.
I am assuming that taud is the adjecency matrix and sir is the weights matrix.
Following is a modification to the function you gave:
function [derajat, derajatmax, dremax1, dremax, maxdegsir, outmagdegsir, m, n, idx_maxsir, taud, derajatmin] = alokasigraph(taud, sir)
derajat = sum(taud);
derajatmax = max(max(derajat));
dremax1 = find(derajat == derajatmax);
dremax = dremax1(1,1);
% Find the minimum degree greater than one
derajat_filtered = derajat(derajat > 1);
if isempty(derajat_filtered)
derajatmin = NaN; % No degree greater than one found
else
derajatmin = min(derajat_filtered);
end
% Continue with the existing logic
maxdegsir = sir;
outmagdegsir = max(max(maxdegsir(:, dremax), [], 'all'));
[m, n] = find(maxdegsir == outmagdegsir);
idx_maxsir = [m(1), n(1)];
maxdegsir(m(1), :) = 0;
maxdegsir(:, n(1)) = 0;
taud(m(1), :) = 0;
taud(:, n(1)) = 0;
end
I Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by