|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- function [ affinity ] = CalcAffinityByCommonNeighbors_Sparse( data, actual_graph_size, num_missing_nodes, num_attr_nodes, attWeight, addMissingAtt )
- %UNTITLED Summary of this function goes here
- % Detailed explanation goes here
-
- %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
-
- % affinity = sparse(size(data,1), size(data,2));
- %
- % num_neighbors = full(sum(data));
- %
- % for i = 1 : size(data,1)
- % %i
- % num_neighbors_i = num_neighbors(i);
- % for j = i : size(data,1)
- % num_neighbors_j = num_neighbors(j);
- % num_common_neighbors = nnz((data(i,:)) & (data(j,:)));
- % if data(i,j) > 0
- % num_common_neighbors = num_common_neighbors + 2; %add one for each direction of the link
- % end
- % % num_common_neighbors = 0;
- % % if data(i,j) == 1
- % % num_common_neighbors = 1;
- % % end
- % % for k = 1 : size(data,1)
- % % if data(i,k) == 1 && data(j,k) == 1
- % % num_common_neighbors = num_common_neighbors + 1;
- % % end
- % % end
- %
- %
- % affinity(i,j) = max(max(num_common_neighbors / num_neighbors_i, num_common_neighbors / num_neighbors_j),eps);
- %
- % affinity(j,i) = affinity(i,j);
- % end
- % end
-
-
- %%%%%%%%%%%%%%%% Problematic??
- % Sigal 5.3.13: 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
-
- % sigal - oct 12 - bug fix by ron - include the node itself as its friend
- affinity = data1 * data + data1*2; % give the #common neighbors per node pair (nxn)
- s_rows = sum(data1) + 1; % give the #neighbors per node (nx1)?
- %%s_cols = sum(data,2);
-
-
-
- affinity = NormalizeCommonNeighbors(affinity, s_rows); %new mex function
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- % for i = 1 : size(data)
- % affinity(i,:) = affinity(i,:) ./ s_rows(i);
- % affinity(:,i) = affinity(:,i) ./ s_cols(i);
- % end
-
- % %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
|