123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105(**************************************************************************)(* *)(* Ocamlgraph: a generic graph library for OCaml *)(* Copyright (C) 2004-2010 *)(* Sylvain Conchon, Jean-Christophe Filliatre and Julien Signoles *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)(* *)(**************************************************************************)(** {2 Mapping of vertices} *)moduletypeV_SRC=sigtypetmoduleV:Sig.HASHABLEvalfold_vertex:(V.t->'a->'a)->t->'a->'aendmoduletypeV_DST=sigtypettypevertexvalempty:unit->tvaladd_vertex:t->vertex->tendmoduleVertex(G_Src:V_SRC)(G_Dst:V_DST)=structmoduleH=Hashtbl.Make(G_Src.V)letvertices=H.create97letconvert_vertexfx=tryH.findverticesxwithNot_found->letx'=fxinH.addverticesxx';x'letmapfg=H.clearvertices;G_Src.fold_vertex(funxg->G_Dst.add_vertexg(convert_vertexfx))g(G_Dst.empty())letfilter_mapfg=G_Src.fold_vertex(funxg->matchfxwith|Somee->G_Dst.add_vertexge|None->g)g(G_Dst.empty())end(** {2 Mapping of edges} *)moduletypeE_SRC=sigtypetmoduleE:Sig.ORDERED_TYPEvalfold_edges_e:(E.t->'a->'a)->t->'a->'aendmoduletypeE_DST=sigtypettypeedgevalempty:unit->tvaladd_edge_e:t->edge->tendmoduleEdge(G_Src:E_SRC)(G_Dst:E_DST)=structmoduleM=Map.Make(G_Src.E)letedges=refM.emptyletconvert_edgefx=tryM.findx!edgeswithNot_found->letx'=fxinedges:=M.addxx'!edges;x'letmapfg=edges:=M.empty;G_Src.fold_edges_e(funxg->G_Dst.add_edge_eg(convert_edgefx))g(G_Dst.empty())letfilter_mapfg=G_Src.fold_edges_e(funxg->matchfxwith|Somee->G_Dst.add_edge_ege|None->g)g(G_Dst.empty())end(*
Vertex
(struct include G_Src module V = E let fold_vertex = fold_edges_e end)
(struct include G_Dst type vertex = edge let add_vertex = add_edge_e end)
*)