function e = vertex_to_edge ( v )

%*****************************************************************************80
%
%% vertex_to_edge() converts a polyiamond description from vertex to edge.
%
%  Discussion:
%
%    The vertex list of a polyiamond gives the IJ coordinates of the
%    polygonal vertices, in counterclockwise order.
%
%    The edge list contains the sequence of parallelogram IJ coordinates
%    of the nodes that lie on the boundary of the polyiamond, listed
%    in counterclockwise order.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer V(VN,2), the IJ parallelogram point coordinates of the 
%    vertices bounding the polyiamond. 
%
%  Output:
%
%    integer E(EN,2), the IJ parallelogram point coordinates of the
%    nodes that lie on the boundary of the polyiamond.
%
  vn = size ( v, 1 );

  e = [];

  i = v(vn,1);
  j = v(vn,2);
% e = [ i, j ];

  for k = 1 : vn

    iold = i;
    jold = j;

    i = v(k,1);
    j = v(k,2);

    while ( i == iold && jold < j )
      jold = jold + 1;
      e = [ e; iold, jold ];
    end

    while ( iold < i && jold == j )
      iold = iold + 1;
      e = [ e; iold, jold ];
    end

    while ( iold < i && jold > j )
      iold = iold + 1;
      jold = jold - 1;
      e = [ e; iold, jold ];
    end

    while ( iold == i && jold > j )
      jold = jold - 1;
      e = [ e; iold, jold ];
    end

    while ( iold > i && jold == j )
      iold = iold - 1;
      e = [ e; iold, jold ];
    end

    while ( iold > i && jold < j )
      iold = iold - 1;
      jold = jold + 1;
      e = [ e; iold, jold ];
    end

  end

  return
end

