Algorithm description for the (distance) skeleton plugin

Hi all,
I am trying to reproduce (in R) the beautiful results I get with the G’MIC Contours>Skeleton filter (distance algo), so that I can get a vector (SVG) version of it (suitable for my Axidraw).
Is there a detailed description of the underlying algorithm somewhere?
I have tried a distance transform in R (distance_transform() function from imager package) and thought extracting the edge lines of it would do the job. But it looks like this is a little bit more complicated: Apart from the lines joining the main skeleton to the boundaries of my subject (a dancer), I also see additional small vertical lines joining these lines in the G’MIC output, that do not seem to come from a simple distance transform.
Is there some kind of recursive application of the distance transform in the G’MIC plugin?
Thank you in advance for your help.
P.S. If G’MIC itself has the ability to export the result in SVG, that would be fine for my current need!

If I run the plug-in, and select filter Contours / Skeleton, then copy the G’MIC command to clipboard, I get this:

fx_skeleton 0,0,0,50,50

Looking in the G’MIC stdlib, I find the definition of this function, around line 48000, and the “Distance” algo looks basically like this with the default parameters, and code comments added:

  >= 50%      # Threshold by the value (min + max)/2 -> get a binarized image
  distance 0  # Compute the distance function to value 0
  sharpen 1e10 # Apply aggressive sharpening filter to the distance function -> This is where the magic happens!
  >= 100% # Binarize, by keeping only the pixels with the max values.
  +erode 2 - * 255 # Remove "doubled" pixels in the skeleton.

So basically, the idea is to apply a sharpen filter to the distance function.
Command sharpen itself is a G’MIC command that is based on inverse diffusion, and can be basically reduced as:

sharpen :
  im,iM:=[im,iM] +laplacian *. {$1/abs(maxabs(im,iM))} - c $im,$iM

This being said, it’s important to understand that this skeleton filter basically uses filtering techniques, so operations at the pixel level. At the end you end up with a binarized image (black and white pixels), and if you want to convert it in SVG described e.g. as a set of segments, then it won’t be that easy.
I think using a bitmap vectorizing tool could be a reasonnable solution to try.

But as it is done actually, I don’t see how you could get a vectorized representation of the obtained skeleton, without an explicit vectorization step (which G’MIC does not have).

Hello David,
Thank you for your quick and detailed answer.
I was able to get pretty close to the G’mic result, except for the colors.
“Looking in the G’MIC stdlib”: Are you referring to the file
As to the final conversion to a SVG, I am experimenting several solutions, in particular a Minimum Spanning Tree.