5 val addnode : graph -> node -> node list -> graph
6 val addedge : graph -> node -> node -> graph
7 val isdag : graph -> node -> bool
10 functor Graph (structure Node : ORD_KEY) :> GRAPH where type node = Node.key =
12 structure Map = SplayMapFn(Node)
13 structure Set = HashSetFn(Node)
15 type graph = (Set.set) Map.map
17 (* val addnode : graph -> node -> node list -> graph
18 * adds a node given its links (directed)
22 of SOME(ns) => Map.insert (g, n, Set.addList (ns, nl))
23 | NONE => Map.insert (g, n, Set.addList (Set.empty, nl))
27 val set1 = case Map.find (g,n1) of SOME(a) => a | NONE => Set.empty
28 val set2 = case Map.find (g,n2) of SOME(a) => a | NONE => Set.empty
30 Map.insert (Map.insert (g, n2, set2), n1, Set.add (set1, n2))
35 val nn = Set.numItems (case Map.find (g,n) of SOME(a) => a | NONE => Set.empty)