You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CalcPHsAffinityByRCN.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function [ affinity ] = CalcPHsAffinityByRCN( data, actual_graph_size, num_missing_nodes, num_attr_nodes, attWeight, addMissingAtt)
  2. % sigal 29.10.13
  3. % based on CalcAffinityByCommonNeighbors_Sparse
  4. if nargin < 4
  5. num_attr_nodes = 0;
  6. addMissingAtt = 0;
  7. attWeight = 0;
  8. fprintf('run ConnectMissingNodesToNeighborsNeighbors without attributes nodes\n');
  9. end
  10. %since missing nodes are only connected to one node we will artificially
  11. %connect them to their only neighbor's neighbors, and keep the connection to
  12. %the neighbor itself.
  13. if nargin > 1
  14. data = ConnectMissingNodesToNeighborsNeighbors(data, actual_graph_size, num_missing_nodes, num_attr_nodes, addMissingAtt);
  15. end
  16. firstPH = actual_graph_size-num_missing_nodes+1;
  17. % Sigal 10.2.14: normalizeWeight
  18. % make sure that ratio att/link is same w/1-w
  19. if attWeight < 1 && attWeight >= 0
  20. normalizeWeight = attWeight/(1-attWeight);
  21. else
  22. normalizeWeight = 1;
  23. end
  24. data1 = data;
  25. if num_attr_nodes > 0
  26. data1(:, 1:num_attr_nodes) = normalizeWeight * data1(:, 1:num_attr_nodes);
  27. data1(1:num_attr_nodes, :) = normalizeWeight * data1(1:num_attr_nodes, :);
  28. end
  29. % give the #common neighbors per node pair (nxn)
  30. % sigal - oct 12 - bug fix by ron - include the node itself as its friend
  31. affinity = data1(firstPH:end,:) * data(:,firstPH:end) + data(firstPH:end,firstPH:end)*2;
  32. s_rows = sum(data1(:,firstPH:end)) + 1; % give the #neighbors per PH node (nx1)?
  33. %%s_cols = sum(data,2);
  34. affinity = NormalizeCommonNeighbors(affinity, s_rows); %new mex function
  35. %sigal 29.10.13 - normolize by diagonal min
  36. v = diag(affinity);
  37. max_val = min(v);
  38. %max_val = max(max(affinity));
  39. affinity = affinity ./ max_val;
  40. for i = 1 : size(affinity,1)
  41. affinity(i,i) = 1;
  42. end
  43. %sigal 29.10.13 - end
  44. end