📄 gd_buildmutualknngraph.m
字号:
function W = BuildMutualKnnGraph(M,k,which_matrix)% Usage: W = BuildMutualKnnGraph(M,k,which_matrix)%% Input: % M = either the distance or the similarity matrix, needs to be square, symmetric, non-negative% k = connectivity parameter of the kNN graph% which_matrix = either 'sim' or 'dist' (similarity or distance matrix)% % Output: % W = adjacency matrix of the mutual kNN graph%%% For a similarity matrix S, returns the mutual knn graph, edges are weighted by S. % For a distance matrix D, returns the undirected (unweighted!) mutual knn graph. If you want to get % a weighted graph in this case, you need to take care of transforming D to S yourself and then % call the function with a similarity matrix %% Self edges are excluded in both cases. % check: if (size(M,1) ~= size(M,2)) error('Matrix not square!')end% build the directed knn graph: W = GD_BuildDirectedKnnGraph(M,k,which_matrix); % transform it to the mutual one: W = min(W,W');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -