mencari nilai minimum dari algoritma graph
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Jaynik
on 5 Sep 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!
0 Comments
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!