-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from BenMiller3/master
Add dot graph optimizations in reduceDotGraph file, clean up how the …
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |