Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / directed-graph / classify-edges.fun
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2005, 2008 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8(*--------------------------------------------------------*)
9(* Classify Edges *)
10(*--------------------------------------------------------*)
11
12fun classifyEdges g {discover: Node.t -> int,
13 finish: Node.t -> int} =
14 let val cs = {tree = ref [], cross = ref [], back = ref [], forward = ref []}
15 fun classify e = let val n = E.tail e
16 val n' = E.head e
17 in if discover n' > discover n then #forward cs
18 else if finish n' = ~1 then #back cs
19 else #cross cs
20 end
21 in (cs, P.T{handleTreeEdge = LU.push (#tree cs),
22 handleNonTreeEdge = fn e => LU.push (classify e) e,
23 startNode = P.ignore, finishNode = P.ignore,
24 startTree = P.ignore, finishTree = P.ignore,
25 finishDfs = P.ignore})
26 end