improve-affinity-colors ( graph order affinities colors -- )


Vocabulary
compiler.cfg.register-allocation.chordal

Inputs
graphan object
orderan object
affinitiesan object
colorsan object


Outputs
None

Definition


:: improve-affinity-colors
( graph order affinities colors -- )
0 :> passes! t :> changed!
[ changed passes 3 < and ] [
f changed! passes 1 + passes! order <reversed> [| vertex
|
vertex graph at [ colors at ] map
:> used vertex colors at
:> current vertex current affinities colors
affinity-score
:> score! current :> best! vertex affinities at
[ colors at ] map sift [| candidate |
candidate used member?
[ ] [
vertex candidate affinities colors
affinity-score
:> candidate-score candidate-score score >
[ candidate best! candidate-score score! ]
when
] if
] each best current = [ ] [ t changed! ] if
best vertex colors set-at
] each
] while ;