I've found code online to find the clustering coefficients from the adjacency matrix, and i'm trying to understand how it works. So deg and cn are column vectors, but i don't understand what cn(deg>1) or deg(deg>1) actually means. thanks

70 次查看(过去 30 天)
deg = sum(graph, 2); %Determine node degrees cn = diag(graph*triu(graph)*graph); %Number of triangles for each node
%The local clustering coefficient of each node c = zeros(size(deg)); c(deg > 1) = 2 * cn(deg > 1) ./ (deg(deg > 1).*(deg(deg > 1) - 1));

回答(1 个)

Arun Mathamkode
Arun Mathamkode 2018-4-20

This is basically logical indexing. deg>1 returns a logical matrix of size deg with value 1 at coordinates where deg>1 condition is satisfied. This logical matrix then can be used for logical indexing. You refer the following blog for more details.

https://blogs.mathworks.com/loren/2013/02/20/logical-indexing-multiple-conditions/

类别

Help CenterFile Exchange 中查找有关 Coordinate Systems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by