표준 ML에 SCC 알고리즘을 작성해야합니다. 하지만 어떻게해야할지 모르겠다.SML의 강력하게 연결된 구성 요소 (SCC 그래프 알고리즘)
type vertex = int
type edge = int * int
type graph = (vertex * vertex list) list
fun dfs (g: graph) (n: vertex): vertex list =
let
fun helper (todo: vertex list) (visited: vertex list): vertex list =
case todo of
[] => []
| h::t => if (List.exists (fn x => x = h) visited)
then helper t visited
else
let
val adj = case List.find (fn (n, _) => n = h) g of
NONE => raise Fail "incomplete adjacency list"
| SOME (_, adj) => adj
in
h :: (helper (adj @ t) (h::visited))
end
in
helper [n] []
end
위의 코드를 컴파일하고 제대로 실행되었습니다
나는 코드를 위해서 사용할 수있는 유형을 다음했다.
SCC에서 dfs가 필요하다는 것을 알고 있기 때문에 이것을 코드에 넣었습니다.
해결책이있는 사람이 있습니까?
무엇이 문제입니까? –
내가 scc ml 코드를 원한다 – JGC
s3nd m3 cod3z 질문은 일반적으로 잘 실행되지 않는다. –