package com.correx.core.validation.policy

import com.correx.core.events.types.StageId
import com.correx.core.transitions.graph.TransitionEdge
import java.util.*

object CycleSignatureFactory {
    fun from(nodes: List<StageId>, edges: List<TransitionEdge>): CycleSignature {
        val nodeSet = TreeSet<StageId>(compareBy { it.value })
        nodeSet.addAll(nodes)

        val edgeSet = TreeSet<Pair<StageId, StageId>>(
            compareBy({ it.first.value }, { it.second.value })
        )
        edges.forEach { edgeSet.add(it.from to it.to) }

        return CycleSignature(nodes = nodeSet, edges = edgeSet)
    }
}
