フィルターのクリア

find node with maximum degree

3 ビュー (過去 30 日間)
Hemiru
Hemiru 2022 年 6 月 21 日
コメント済み: Hemiru 2022 年 6 月 22 日
Hello !!
I have nodes 1 to 30 with degree
node = [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
degre = [ 11 11 12 10 15 10 8 14 12 1 8 6 2 18 5 3 7 4 15 2 0 0 0 0 0 0 0 0 0 0 ]
how to find node with maximum degree and label it xi .?
i tried using [B,I] = maxk(deg,node); but it doesn't work. because the degree value is always changing
should node 14 with degree 18 be labeled 1 and ect, until all nodes are labeled
thank you
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2022 年 6 月 21 日
If you want to get the values from the arrays -
node=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30];
degree=[11 11 12 10 15 10 8 14 12 1 8 6 2 18 5 3 7 4 15 2 0 0 0 0 0 0 0 0 0 0];
[degmax,idx]=max(degree)
degmax = 18
idx = 14
node(idx)
ans = 14
Hemiru
Hemiru 2022 年 6 月 21 日
thank for the anwers Dyuman joshi
but, how can i check all the nodes by degree using loop and label them according to the highest to lowest degree.
exp
node = [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ]
degre = [ 11 11 12 10 15 10 8 14 12 1 8 6 2 18 5 ]
label = [6 7 4 8 2 9 10 3 5 10 11 12 14 1 15 ]

サインインしてコメントする。

回答 (1 件)

Dyuman Joshi
Dyuman Joshi 2022 年 6 月 22 日
Your "label" seems incorrect.
node=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15];
degree=[11 11 12 10 15 10 8 14 12 1 8 6 2 18 5];
deg=unique(degree,'stable'); %for comparing individual elements
z=zeros(size(degree)); %pre-allocating array
y=sort(degree,'descend'); %sorting descendingly, to get highest-to-lowest
for i=1:numel(deg)
z(degree==deg(i))=find(y==deg(i));
end
z
z = 1×15
6 7 4 8 2 9 10 3 5 15 11 12 14 1 13
  1 件のコメント
Hemiru
Hemiru 2022 年 6 月 22 日
Thank you very much Dyuman Joshi for your help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by