Skip to content

Instantly share code, notes, and snippets.

@5outh
Created December 5, 2012 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5outh/4219922 to your computer and use it in GitHub Desktop.
Save 5outh/4219922 to your computer and use it in GitHub Desktop.
Graph from file
graphFromFile :: String -> IO (Graph String)
graphFromFile f = do
contents <- readFile f
let info = map words $ lines contents
verts = nub . concat $ info
conns = map (\[a, b] -> (a, b)) info
graph = Graph verts conns
return graph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment