Skip to content

Commit

Permalink
Merge pull request #81 from BenMiller3/master
Browse files Browse the repository at this point in the history
Add dot graph optimizations in reduceDotGraph file, clean up how the …
  • Loading branch information
CSchank authored May 6, 2019
2 parents 3d0e564 + 76f05e2 commit 6157bf8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Generate/ReduceDotGraph.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{-# LANGUAGE OverloadedStrings #-}

import System.IO
import System.Environment
import Data.List

loadDotGraph :: FilePath -> IO String
loadDotGraph fileName = readFile fileName

removeDuplicates :: (Eq a) => [a] -> [a]
removeDuplicates list = remDups list []

remDups :: (Eq a) => [a] -> [a] -> [a]
remDups [] _ = []
remDups (x:xs) list2
| (x `elem` list2) = remDups xs list2
| otherwise = x : remDups xs (x:list2)

reduceDotGraph :: FilePath -> IO ()
reduceDotGraph dotGraph = do
str <- loadDotGraph dotGraph
let lst = lines str
let noDups = removeDuplicates lst
-- Remove self transitions from reduced output
let noSelfTransitions = [n | n <- noDups, isInfixOf "style=dashed" n == False]
let strReduced = intercalate "\n" noSelfTransitions
writeFile (dotGraph ++ "_reduced.dot") strReduced

0 comments on commit 6157bf8

Please sign in to comment.