12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- function [ affinity ] = CalcAffinityByCommonNeighbors( data, actual_graph_size, num_missing_nodes )
- %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);
- end
-
- affinity = zeros(size(data,1), size(data,2));
-
-
- for i = 1 : size(data,1)
- num_neighbors_i = sum(data(i,:));
- for j = i : size(data,1)
- num_neighbors_j = sum(data(j,:));
- num_common_neighbors = sum((data(i,:)) > 0 & (data(j,:) > 0));
- 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
-
- %set the lowest affinity to epsilon
- %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
-
-
-
- end
-
|