Function validateClosedPath

Validates if the given line indices form a closed path in the element