Home > Mateda2.0 > learning > FactAffinity.m

# FactAffinity

## PURPOSE

[Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)

## SYNOPSIS

function [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)

## DESCRIPTION

     [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)
     FactAffinity:   Finds a set of cliques from a matrix of mutual information
                    using affinity propagation
     INPUTS:
     NumbVar: Number of variables
     dim: Number of previous variables each variables depends on
     OUTPUTS:
     Cliques: Structure of the model in a list of cliques that defines the (chain shaped)  junction tree.
              Each row of Cliques is a clique. The first value is the number of overlapping variables.
              The second, is the number of new variables.
              Then, overlapping variables are listed and  finally new variables are listed.
     Last version 8/26/2008. Roberto Santana and Siddarta Shakya (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

- FactAffinity [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)
- apcluster This program has been downloaded from

This function is called by:

- FactAffinity [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)

## SOURCE CODE

    0001 function [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)
    0002 % [Cliques,deep]=FactAffinity(MI,vars,sizeconstraint,p,deep)
    0003 % FactAffinity:   Finds a set of cliques from a matrix of mutual information
    0004 %                using affinity propagation
    0005 % INPUTS:
    0006 % NumbVar: Number of variables
    0007 % dim: Number of previous variables each variables depends on
    0008 % OUTPUTS:
    0009 % Cliques: Structure of the model in a list of cliques that defines the (chain shaped)  junction tree.
    0010 %          Each row of Cliques is a clique. The first value is the number of overlapping variables.
    0011 %          The second, is the number of new variables.
    0012 %          Then, overlapping variables are listed and  finally new variables are listed.
    0013 % Last version 8/26/2008. Roberto Santana and Siddarta Shakya (roberto.santana@ehu.es)
    0014
    0015
    0016 if deep>=10
    0017    MI = MI + rand(size(MI));
    0018 end
    0019 deep = deep + 1;
    0020 n = size(MI,1);
    0021  vars
    0022 [idx,netsim,dpsim,expref]=apcluster(MI,p); %Find the clusters of the MI matrix
    0023 Cliques = [];
    0024 nclusters = length(unique(idx));
    0025 exemplars = unique(idx);
    0026 for i=1:nclusters
    0027  clusters{i} = find(idx==exemplars(i));
    0028  clustsize = size(clusters{i},1);
    0029  if(clustsize>sizeconstraint)
    0030     MI1 = MI(:,clusters{i});
    0031     MI1 = MI1(clusters{i},:);
    0032     p=  (max(MI1(:))-min(MI1(:)))*rand();  % Set preference to median similarity
    0033     olddeep = deep;
    0034     [Cliques1,deep]=FactAffinity(MI1,vars(clusters{i}'),sizeconstraint,p,deep);
    0035     deep = olddeep;
    0036    Cliques = [Cliques;Cliques1];
    0037  else
    0038    %vars(clusters{i}')'
    0039    Cliq = [0,clustsize,vars(clusters{i}'),zeros(1,sizeconstraint+2-clustsize)];
    0040    Cliques = [Cliques;Cliq];
    0041  end
    0042 end
    0043
    0044
    0045
    0046
    0047
    0048
    0049
    0050
    0051
    0052