Is module DFS really needed?

Abierto
#232 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Refactorización
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
haskell
Área
compilers

Línea de trabajo

Empieza inspeccionando DFS y su uso externo desde NFA.hs; después, compara el comportamiento requerido con Data.Graph de la dependencia containers. Comprueba las versiones de GHC compatibles antes de decidir si el reemplazo es viable. Se considera terminado cuando existe una decisión documentada, se ha eliminado el código no utilizado o se ha implementado el reemplazo, preservando el comportamiento requerido del grafo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The module DFS implements graph algorithms. From that module, only the functions out and t_close are used externally (in NFA.hs). The functions list_tree, mk_graph, edges, rev_edges, reverse_graph, scc, top_sort and dff, and the type Edge, are not used.

However, there's something else that strikes me from that module, and points to a potential cleaning opportunity:

  • The top comment reads "This module is a portable version of [...] [an] encoding of [...] linear graph algorithms. This module uses balanced binary trees instead of mutable arrays to implement the depth-first search so the complexity of the algorithms is n.log(n) instead of linear." However, isn't linear better than n times log(n)??? Why go for the latter if you can opt for the former?

  • There is an implementation of graphs in Data.Graph in containers (and containers is already a dependency of alex), although I haven't checked if that was there already in the earliest version of GHC supported by alex, which I think is GHC 7 (?). The two functions used externally, out and t_close, could be defined, if I understand their purpose correctly, as:

out :: Graph -> Int -> [Int]
out = Data.Array.(!)

t_close :: Graph -> Graph
t_close g = buildG (bounds g) [ (v1, v2) | v1 <- vertices g, v2 <- reachable g v1 ]

List comprehensions are generally slower than map so there's probably a faster way of building t_close if performance is an issue here.

My questions are:

  1. Should this module be replaced by a use of Data.Graph?
  2. If not, should the unused functions mentioned above be removed?
Lenguaje dominante
Haskell
Estrellas
323
Forks
87
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de haskell/alex

Todos los issues de haskell/alex

Issues similares

Más issues de Haskell

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.