adjacency matrix to boolean matrix convert

4 ビュー (過去 30 日間)
D N
D N 2016 年 3 月 13 日
コメント済み: Walter Roberson 2016 年 4 月 4 日
I would like to ask if someone know how to convert a matrix based on number of contacts between nodes to a boolean matrix. With boolean matrix I would like to create a k-clique community. thanks for the answers
  8 件のコメント
D N
D N 2016 年 4 月 4 日
quality will show me how good is the conenction between nodes and quality I calculate as you can see in code below:
max = max(max(socialna_mat));% max value in social matrix
por_soc=1;
vektor_por_hodnot=zeros(1,20);
percenta=5;%value in percents;
while por_soc==1
porov_hodnota=max/100*percenta;
bool_soc_mat=zeros(size(socialna_mat,2));
for o=1:size(socialna_mat,2)
for j=1:size(socialna_mat,2)
if socialna_mat(o,j)>=porov_hodnota
bool_soc_mat(o,j)=1;
end
if socialna_mat(o,j)<porov_hodnota
bool_soc_mat(o,j)=0;
end
end
end
m=sum(sum(socialna_mat))/2;
sum_ij=0;
for i=1:size(socialna_mat,2)
for j=1:size(socialna_mat,2)
k_i=sum(socialna_mat(i,:));
k_j=sum(socialna_mat(:,j));
A_ij=socialna_mat(i,j);
sum_ij=sum_ij+(A_ij-(k_i*k_j)/(2*m))*bool_soc_mat(i,j);
end
end
Q=1/(2*m)*sum_ij;
Walter Roberson
Walter Roberson 2016 年 4 月 4 日
You can remove a couple of loops from that code. Your "for o" nested loop can be replaced by
bool_soc_mat = socialna_mat >= porov_hodnota;
By the way, please do not use "max" as the name of a variable, as that interferes with using it as the function max()

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

回答 (1 件)

Ahmet Cecen
Ahmet Cecen 2016 年 3 月 19 日
編集済み: Ahmet Cecen 2016 年 3 月 19 日
Sounds like what you want is simply:
CliqueMatrix = AdjacencyMatrix >= Threshold;
Then you would sum along the columns and find if that value is bigger than your k:
sum(CliqueMatrix) >= k
This would give you ones for nodes that are a member of a clique with at least size k.
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 3 月 20 日
That would not tell you which nodes were members of cliques: it would tell you which nodes have at least that many adjacent members.
The information can be used to help filter the possibilities, in that any node that does not have at least (k-1) adjacent vertices cannot be part of a clique of size k, since cliques are complete subgraphs.
This suggests a procedure to make the problem easier: calculate the degree for each graph, remove the nodes which do not have degree at least k-1. Repeat with the new graph, iterating until either the graph is empty (no cliques large enough) or every remaining node has at least k-1 neighbors. Now with the reduced set of vertices, proceed with the more difficult search.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by