Hi Claudio,
this is a code for the DFS search. It assumes the graph is represented, as in your code, as an edge list.
And, as in your code, the output is a path from a start_node to a finale_node (if it exists).
import Data.Maybe
dfs_search :: Int -> Int -> [(Int,Int)]-> [Int]
dfs_search sn fn graph = dfs_search_aux sn fn graph [sn] [sn]
dfs_search_aux :: Int -> Int -> [(Int,Int)] -> [Int] -> [Int] -> [Int]
dfs_search_aux sn fn graph visited path
|sn==fn = path
|not (isNothing neighbour) = dfs_search_aux x fn graph (x:visited) (path++[x])
|has_length_1 path = error "NO SOLUTION"
|otherwise = dfs_search_aux (last new_path) fn graph visited new_path
where neighbour=not_visited_neighbour sn visited graph
x = fromJust neighbour
new_path= init path
not_visited_neighbour :: Int -> [Int] -> [(Int,Int)] -> Maybe Int
not_visited_neighbour _ _ [] = Nothing
not_visited_neighbour x visited ((a,b):xs)
| (x == a) && not (elem b visited) = Just b
| (x == b) && not (elem a visited) = Just a
| otherwise = not_visited_neighbour x visited xs
has_length_1 :: [Int]->Bool
has_length_1 [] = False
has_length_1 (x:xs) = xs==[]
Cheers,
Ut