Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of sladjlist2edgeset
Home > sltoolbox > graph > sladjlist2edgeset.m

sladjlist2edgeset

PURPOSE ^

SLADJLIST2EDGESET Converts the adjacency list to edge set

SYNOPSIS ^

function edges = sladjlist2edgeset(targets, sch)

DESCRIPTION ^

SLADJLIST2EDGESET Converts the adjacency list to edge set

 $ Syntax $
   - edges = sladjlist2edgeset(targets, sch)

 $ Arguments $
   - targets:      The targets in adj list (length-n cell array)
   - sch:          The scheme of conversion
                   - 0: no value -> no value
                   - 1: no value -> has value
                   - 2: has value -> no value
                   - 3: has value -> has value
   - edges:        The edge set (nedges x 2 or nedges x 3 matrix)
 
 $ Remarks $
   - an internal function for graph representation conversion.
     no checking of input arguments would be performed.

 $ History $
   - Created by Dahua Lin, on Sep 9, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slexpand SLEXPAND Expand a set to multiple instance
This function is called by:
  • sladjmat SLADJMAT Constructs the adjacency matrix representation of a graph
  • sledgeset SLEDGESET Construct the edge set representation of a graph
  • slnngraph SLNNGRAPH Constructs a nearest neighborhood based graph

SOURCE CODE ^

0001 function edges = sladjlist2edgeset(targets, sch)
0002 %SLADJLIST2EDGESET Converts the adjacency list to edge set
0003 %
0004 % $ Syntax $
0005 %   - edges = sladjlist2edgeset(targets, sch)
0006 %
0007 % $ Arguments $
0008 %   - targets:      The targets in adj list (length-n cell array)
0009 %   - sch:          The scheme of conversion
0010 %                   - 0: no value -> no value
0011 %                   - 1: no value -> has value
0012 %                   - 2: has value -> no value
0013 %                   - 3: has value -> has value
0014 %   - edges:        The edge set (nedges x 2 or nedges x 3 matrix)
0015 %
0016 % $ Remarks $
0017 %   - an internal function for graph representation conversion.
0018 %     no checking of input arguments would be performed.
0019 %
0020 % $ History $
0021 %   - Created by Dahua Lin, on Sep 9, 2006
0022 %
0023 
0024 %% get J and V
0025 
0026 n = length(targets);
0027 jv = vertcat(targets{:});
0028 
0029 if ~isempty(jv)
0030     if sch == 1
0031         nedges = size(jv, 1);
0032         jv = [jv, ones(nedges, 1)];
0033     elseif sch == 2
0034         jv = jv(:,1);
0035     end
0036 else
0037     edges =[];
0038     return;
0039 end
0040         
0041 %% add I
0042 
0043 nums = zeros(n, 1);
0044 for i = 1 : n
0045     cinds = targets{i};
0046     if ~isempty(cinds)
0047         nums(i) = size(cinds, 1);
0048     end
0049 end
0050 ic = slexpand(nums);
0051 edges = [ic, jv];
0052 
0053

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com