Home > Mateda2.0 > knowledge_extraction > visualization > Find_indexmatrix.m

# Find_indexmatrix

## PURPOSE

[m,indexmatrix] = Find_indexmatrix(n)

## SYNOPSIS

function[m,indexmatrix] = Find_indexmatrix(n)

## DESCRIPTION

     [m,indexmatrix] = Find_indexmatrix(n)
     Find_indexmatrix:   Given a number of variables, creates a structure that
                         associates an index to every possible edge of a full structure (all related
                         variables)
     INPUTS
     n: Number of variables
     OUTPUTS
     m: Number of variables
     indexmatrix: Matrix where entry i,j has the associated index of edge i,j.

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- ReadBNStructures [run_structures,maxgen,nruns] = ReadBNStructures(n, maxgen,
- ReadMNStructures [run_structures] = ReadMNStructures(n, maxgen, nruns,AllModels)
- ReadStructures [run_structures,maxgen,nruns] = ReadStructures(namefile,n)

## SOURCE CODE

    0001 function[m,indexmatrix] = Find_indexmatrix(n)
    0002 % [m,indexmatrix] = Find_indexmatrix(n)
    0003 % Find_indexmatrix:   Given a number of variables, creates a structure that
    0004 %                     associates an index to every possible edge of a full structure (all related
    0005 %                     variables)
    0006 % INPUTS
    0007 % n: Number of variables
    0008 % OUTPUTS
    0009 % m: Number of variables
    0010 % indexmatrix: Matrix where entry i,j has the associated index of edge i,j.
    0011 %
    0012 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0013
    0014
    0015 m = n*(n+1)/2; % Number of possible edges
    0016
    0017 indexmatrix = zeros(n,n);  % Matrix of indices for edges
    0018 a= 1;
    0019 for i=1:n-1
    0020  for j=i+1:n
    0021   indexmatrix(i,j) = a;    % Each edge has an associated index
    0022   indexmatrix(j,i) = a;
    0023   a = a + 1;
    0024  end
    0025 end