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

16 views (last 30 days)
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));

Answers (1)

Arun Mathamkode
Arun Mathamkode on 20 Apr 2018

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/

Categories

Find more on 3-D Scene Control 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!