Lines between vertices

If the curve segments between the vertex points were straight lines (they are not in your image) and if their start/end points are aligned and if the polylines have matching directions…

Discontinuity Flip Matrix Line

You didn’t post a GH file with internalized geometry, as recommended, so help is limited.

3. Attach minimal versions of all the relevant files