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 sledgeset2adjlist
Home > sltoolbox > graph > sledgeset2adjlist.m

sledgeset2adjlist

PURPOSE ^

SLEDGESET2ADJLIST Converts edge set to adjacency list

SYNOPSIS ^

function targets = sledgeset2adjlist(n, edges, sch)

DESCRIPTION ^

SLEDGESET2ADJLIST Converts edge set to adjacency list

 $ Syntax $
   - targets = sledgeset2adjlist(n, edges, sch)

 $ Arguments $
   - n:        The number of (source) nodes
   - edges:    The set of edges (nedges x 2 or nedges x 3)
   - sch:      The id of scheme of conversion to take
               - 0:    no value -> no value
               - 1:    no value -> has value
               - 2:    has value -> no value
               - 3:    has value -> has value
   - targets:  The cell array of targets in adj list

 $ 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:
  • slcount SLCOUNT Count the number of sum entities
  • slnums2bounds SLNUMS2BOUNDS Compute the index-boundaries from section sizes
This function is called by:
  • sladjlist SLADJLIST Construct the adjacency list representation of a graph

SOURCE CODE ^

0001 function targets = sledgeset2adjlist(n, edges, sch)
0002 %SLEDGESET2ADJLIST Converts edge set to adjacency list
0003 %
0004 % $ Syntax $
0005 %   - targets = sledgeset2adjlist(n, edges, sch)
0006 %
0007 % $ Arguments $
0008 %   - n:        The number of (source) nodes
0009 %   - edges:    The set of edges (nedges x 2 or nedges x 3)
0010 %   - sch:      The id of scheme of conversion to take
0011 %               - 0:    no value -> no value
0012 %               - 1:    no value -> has value
0013 %               - 2:    has value -> no value
0014 %               - 3:    has value -> has value
0015 %   - targets:  The cell array of targets in adj list
0016 %
0017 % $ Remarks $
0018 %   - an internal function for graph representation conversion.
0019 %     no checking of input arguments would be performed.
0020 %
0021 % $ History $
0022 %   - Created by Dahua Lin, on Sep 9, 2006
0023 %
0024 
0025 %% prepare storage
0026 
0027 targets = cell(n, 1);
0028 
0029 %% sort edges
0030 
0031 I = edges(:, 1);
0032 J = edges(:, 2);
0033 
0034 [I, si] = sort(I);
0035 J = J(si);
0036 
0037 if sch == 3
0038     V = edges(si, 3);
0039 elseif sch == 1
0040     nedges = length(I);
0041     V = ones(nedges, 1);
0042 end
0043 
0044 %% group targets
0045 
0046 nums = slcount(I);
0047 ni = length(nums);
0048 [spos, epos] = slnums2bounds(nums);
0049 
0050 if sch == 1 || sch == 3
0051     for i = 1 : ni
0052         s = spos(i); e = epos(i);
0053         if s <= e
0054             targets{I(s)} = [J(s:e), V(s:e)];
0055         end
0056     end
0057 else
0058     for i = 1 : ni
0059         s = spos(i); e = epos(i);
0060         if s <= e
0061             targets{I(s)} = J(s:e);
0062         end
0063     end
0064 end
0065 
0066 
0067

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

Contact us at files@mathworks.com