You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: boundaryGraph.m
    path of file: ./repos/matGeom/matGeom/graphs
    
    the code of the file until where you have to start completion: function varargout = boundaryGraph(img)
%BOUNDARYGRAPH Get boundary of image as a graph.
%
%   deprecated: use imageBoundaryGraph instead
%
%   [NODES, EDGES] = boundaryGraph(IMG)         (2D)
%   [NODES, EDGES, FACES] = boundaryGraph(IMG)  (3D)
%   Create a graph on the boundary of binary image IMG. Each pixel is
%   considered as a unit square (or cube), centered on integer coordinates. 
%   Boundary of the shape is selected as a graph.
%
%   Result is a set of nodes with (x,y) or (x,y,z) coordinates, a set of
%   edges linking two neighbour nodes, and in 3D also a set of square
%   faces, containing reference to each 4-tuple of nodes.
%   
%   The resulting shell is open if the binary structure touches edges of
%   image.
%
%   See als:
%     imageBoundaryGraph
%

    
function varargout = boundaryGraph(img)
%BOUNDARYGRAPH Get boundary of image as a graph.
%
%   deprecated: use imageBoundaryGraph instead
%
%   [NODES, EDGES] = boundaryGraph(IMG)         (2D)
%   [NODES, EDGES, FACES] = boundaryGraph(IMG)  (3D)
%   Create a graph on the boundary of binary image IMG. Each pixel is
%   considered as a unit square (or cube), centered on integer coordinates. 
%   Boundary of the shape is selected as a graph.
%
%   Result is a set of nodes with (x,y) or (x,y,z) coordinates, a set of
%   edges linking two neighbour nodes, and in 3D also a set of square
%   faces, containing reference to each 4-tuple of nodes.
%   
%   The resulting shell is open if the binary structure touches edges of
%   image.
%
%   See als:
%     imageBoundaryGraph
%

% ------
% Author: David Legland 
% E-mail: david.legland@inrae.fr
% Created: 2004-06-28
% Copyright 2004-2023 INRA - TPV URPOI - BIA IMASTE

dim = size(img);
nd = length(dim);
if nd==2 && (dim(1)==1 || dim(2)==1)
    nd=1;
end