12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(**************************************************************************)(* *)(* This file is part of Frama-C. *)(* *)(* Copyright (C) 2007-2023 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It 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. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)moduleMake(G:sigincludeGraph.Sig.Gvalcreate:?size:int->unit->tvaladd_edge_e:t->E.t->unitend)(D:Datatype.Swithtypet=G.t)(Info:sigvalself:State.tvalname:stringvalget:unit->G.tvalvertex:Kernel_function.t->G.V.tend)=structmoduleS=State_builder.Option_ref(Datatype.Option(D))(* none if no root is specified *)(structletname="Subgraph of "^Info.nameletdependencies=[Info.self;Options.Roots.self]end)letself=S.selfletcompute=letmoduleHNodes=Hashtbl.Make(G.V)infun()->letg=Info.get()inletroots=Options.Roots.get()inifKernel_function.Set.is_emptyrootsthenNoneelseletsubg=G.create()inletvisited=HNodes.create17inletrecadd_componentv=(* iter over the connected component of [v] for adding every edge to
the subgraph *)ifnot(HNodes.memvisitedv)thenbeginHNodes.addvisitedv();G.iter_succ_e(fune->G.add_edge_esubge;add_component(G.E.dste))gvendinKernel_function.Set.iter(funkf->add_component(Info.vertexkf))roots;Somesubgletget()=matchS.memocomputewith|None->Info.get()(* when no root is specified, use the whole graph *)|Someg->gend(*
Local Variables:
compile-command: "make -C ../../.."
End:
*)