Problem 80b Solutions

adjListToGraph : AdjList comparable -> Graph comparable
adjListToGraph list =
    let
        nodes = List.map Tuple.first list
        edges = List.concatMap buildEdges list
                  |> Set.fromList 
                  |> Set.toList
    in
        (nodes, edges)


buildEdges : (comparable, List comparable) -> List (Edge comparable)
buildEdges (n, list) = 
    List.map (\x -> (min x n, max x n)) list

Back to problem

results matching ""

    No results matching ""