From: Claudio Sacerdoti Coen Date: Thu, 28 Sep 2006 11:51:22 +0000 (+0000) Subject: Implemented topological sorting according to the dependencies. X-Git-Tag: 0.4.95@7852~981 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=1bb5297e44de15e0885e38b6d4a0f0cde3ca1398;p=helm.git Implemented topological sorting according to the dependencies. --- diff --git a/components/metadata/metadataDeps.ml b/components/metadata/metadataDeps.ml index b393dbb91..f2b1d0496 100644 --- a/components/metadata/metadataDeps.ml +++ b/components/metadata/metadataDeps.ml @@ -91,6 +91,16 @@ let inverse_deps ~dbd uri = do_query (MetadataTypes.obj_tbl ()) @ do_query MetadataTypes.library_obj_tbl +let topological_sort ~dbd uris = + let module OrderedUri = + struct + type t = UriManager.uri + let compare = UriManager.compare + end in + let module Topo = HTopoSort.Make(OrderedUri) in + Topo.topological_sort uris + (fun uri -> fst (List.split (direct_deps ~dbd uri))) + module DepGraph = struct module UriTbl = UriManager.UriHashtbl diff --git a/components/metadata/metadataDeps.mli b/components/metadata/metadataDeps.mli index ee0954d05..f5a6ac22e 100644 --- a/components/metadata/metadataDeps.mli +++ b/components/metadata/metadataDeps.mli @@ -35,6 +35,9 @@ val inverse_deps: dbd:HMysql.dbd -> UriManager.uri -> (UriManager.uri * MetadataTypes.position) list +val topological_sort: + dbd:HMysql.dbd -> UriManager.uri list -> UriManager.uri list + (** Representation of a (lazy) dependency graph. * Imperative data structure. *) module DepGraph: