function Q_x = commGSP_signal_modularity(A, signal) % Returns the scalar measure whose positive value reflects how much % a graph signal is modular (more modular than anti-modular). % A negative value reflects more anti-modular features than modular. % The measure is the quadratic form of modularity matrix. % INPUT: % A - (symmetric) matrix to decompose % signal - vector (length equal to size of A) representing graph signal % of size number_of_nodes x 1, or a set of signals organized in a matrix % of size number_of_nodes x number_of_signals % OUTPUT % Q_x - scalar metric of signal's modularity structure, or a vector with % every entry corresponding to one of the signals is signal is a matrix Q = commGSP_build_matrix(A, 'modularity'); Q_x = diag(signal'*Q*signal); end