|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- function [ affinity ] = CalcPHsAffinityByRCN( data, actual_graph_size, num_missing_nodes, num_attr_nodes, attWeight, addMissingAtt)
- % sigal 29.10.13
- % based on CalcAffinityByCommonNeighbors_Sparse
- if nargin < 4
- num_attr_nodes = 0;
- addMissingAtt = 0;
- attWeight = 0;
- fprintf('run ConnectMissingNodesToNeighborsNeighbors without attributes nodes\n');
- end
-
- %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, num_attr_nodes, addMissingAtt);
- end
-
- firstPH = actual_graph_size-num_missing_nodes+1;
-
- % Sigal 10.2.14: normalizeWeight
- % make sure that ratio att/link is same w/1-w
- if attWeight < 1 && attWeight >= 0
- normalizeWeight = attWeight/(1-attWeight);
- else
- normalizeWeight = 1;
- end
- data1 = data;
- if num_attr_nodes > 0
- data1(:, 1:num_attr_nodes) = normalizeWeight * data1(:, 1:num_attr_nodes);
- data1(1:num_attr_nodes, :) = normalizeWeight * data1(1:num_attr_nodes, :);
- end
-
- % give the #common neighbors per node pair (nxn)
- % sigal - oct 12 - bug fix by ron - include the node itself as its friend
- affinity = data1(firstPH:end,:) * data(:,firstPH:end) + data(firstPH:end,firstPH:end)*2;
- s_rows = sum(data1(:,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
|