mencari nilai minimum dari algoritma graph

1 visualización (últimos 30 días)
Fawwaz
Fawwaz el 31 de Ag. de 2022
Respondida: Jaynik el 5 de Sept. de 2024
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

Respuestas (1)

Jaynik
Jaynik el 5 de Sept. de 2024
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!

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by