X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/1144856ba9d6018d9922c6ede7e97779a0fe6373..5c79bb689ab446551bc7ec4497e6c9b75582837e:/util/graph.sml diff --git a/util/graph.sml b/util/graph.sml deleted file mode 100644 index 502cd7c..0000000 --- a/util/graph.sml +++ /dev/null @@ -1,40 +0,0 @@ -signature GRAPH = -sig - type node - type graph - val addnode : graph -> node -> node list -> graph - val addedge : graph -> node -> node -> graph - val isdag : graph -> node -> bool -end - -functor Graph (structure Node : ORD_KEY) :> GRAPH where type node = Node.key = -struct - structure Map = SplayMapFn(Node) - structure Set = HashSetFn(Node) - type node = Node.key - type graph = (Set.set) Map.map - - (* val addnode : graph -> node -> node list -> graph - * adds a node given its links (directed) - *) - fun addnode g n nl = - case Map.find (g,n) - of SOME(ns) => Map.insert (g, n, Set.addList (ns, nl)) - | NONE => Map.insert (g, n, Set.addList (Set.empty, nl)) - - fun addedge g n1 n2 = - let - val set1 = case Map.find (g,n1) of SOME(a) => a | NONE => Set.empty - val set2 = case Map.find (g,n2) of SOME(a) => a | NONE => Set.empty - in - Map.insert (Map.insert (g, n2, set2), n1, Set.add (set1, n2)) - end - - fun isdag g n = - let - val nn = Set.numItems (case Map.find (g,n) of SOME(a) => a | NONE => Set.empty) - - in - end - -end