12345678910111213141516171819202122232425262728293031323334 |
- function [ affinity ] = CalcPHsAffinityByRCN( data, actual_graph_size, num_missing_nodes)
- % sigal 29.10.13
- % based on CalcAffinityByCommonNeighbors_Sparse
-
- %since missing nodes are only connected to one node we will artificially
- %connect them to their only neighbor's neighbors, and keep the connection to
- %the neighbor itself.
- if nargin > 1
- data = ConnectMissingNodesToNeighborsNeighbors(data, actual_graph_size, num_missing_nodes);
- end
-
- firstPH = actual_graph_size-num_missing_nodes+1;
-
- % give the #common neighbors per node pair (nxn)
- % sigal - oct 12 - bug fix by ron - include the node itself as its friend
- affinity = data(firstPH:end,:) * data(:,firstPH:end) + data(firstPH:end,firstPH:end)*2;
- s_rows = sum(data(:,firstPH:end)) + 1; % give the #neighbors per PH node (nx1)?
- %%s_cols = sum(data,2);
-
- affinity = NormalizeCommonNeighbors(affinity, s_rows); %new mex function
-
- %sigal 29.10.13 - normolize by diagonal min
- v = diag(affinity);
- max_val = min(v);
- %max_val = max(max(affinity));
-
- affinity = affinity ./ max_val;
-
- for i = 1 : size(affinity,1)
- affinity(i,i) = 1;
- end
- %sigal 29.10.13 - end
-
- end
|