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
0 件のコメント
回答 (1 件)
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!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!