Last active
December 19, 2015 08:49
-
-
Save rblaze/5928545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Vector as V | |
import qualified Data.Vector.Unboxed as U | |
type Coloring = U.Vector Word32 | |
type Links = V.Vector (U.Vector Int) | |
colors :: Coloring | |
links :: Links | |
allColors, deadColors :: U.Vector Color | |
allColors = U.generate nColors fromIntegral | |
deadColors = U.replicate 1000 maxBound | |
n :: Int | |
used = U.filter (< nColors) $ U.map (\i -> fromIntegral $ colors U.! i) (links V.! n) | |
avail = U.update_ allColors used deadColors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allColors - список всех возможных цветов. Из него надо выкинуть (или заменить на 0xfffffffff) все значения, используемые узлами, соединенными с n. | |
(links V.! n) получает номера этих узлов. | |
colors U.! i - цвет узла i, если там maxBound, то узел еще не окрашен. | |
update_ потом меняет в списке всех цветов значения использованых цветов на элементы deadColors. | |
used сейчас жрет 51% CPU сам, 58 с потомками, avail скромнее - 8%. Как их ускорить? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment