From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=AWL,RCVD_NUMERIC_HELO, SPF_SOFTFAIL,UNPARSEABLE_RELAY autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 09C9FBBAF for ; Thu, 12 Mar 2009 08:55:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AroCAAJduEmEpqxrmWdsb2JhbACJEIwPHAEBAQEBCAsKBxFDvDCEDQaEUw X-IronPort-AV: E=Sophos;i="4.38,349,1233529200"; d="scan'208";a="22428763" Received: from sainfoin-out.extra.cea.fr ([132.166.172.107]) by mail2-smtp-roc.national.inria.fr with ESMTP; 12 Mar 2009 08:55:34 +0100 Received: from pisaure.intra.cea.fr (pisaure.intra.cea.fr [132.166.88.21]) by sainfoin.extra.cea.fr (8.14.2/8.14.2/CEAnet-Internet-out-1.2) with ESMTP id n2C7tX3m011495; Thu, 12 Mar 2009 08:55:33 +0100 Received: from muguet1.intra.cea.fr (muguet1.intra.cea.fr [132.166.192.6]) by pisaure.intra.cea.fr (8.14.2/8.14.2) with ESMTP id n2C7vD4C012972; Thu, 12 Mar 2009 08:57:14 +0100 (envelope-from julien.signoles@cea.fr) Received: from levau.intra.cea.fr (levau.intra.cea.fr [132.166.88.52]) by muguet1.intra.cea.fr (8.13.8/8.13.8/CEAnet-Intranet-out-1.1) with ESMTP id n2C7tXhp026014; Thu, 12 Mar 2009 08:55:33 +0100 Received: from LAXA.intra.cea.fr ([132.166.64.47]) by levau.intra.cea.fr with Microsoft SMTPSVC(6.0.3790.3959); Thu, 12 Mar 2009 08:55:32 +0100 Received: from 132.166.135.80 ([132.166.135.80]) by LAXA.intra.cea.fr ([132.166.64.53]) with Microsoft Exchange Server HTTP-DAV ; Thu, 12 Mar 2009 07:55:32 +0000 Received: from is005140 by LAXA.intra.cea.fr; 12 Mar 2009 08:55:49 +0100 Subject: Re: [Caml-list] changing labels on ocamlgraph edges From: Julien SIGNOLES To: Alexy Khrabrov Cc: OCaml In-Reply-To: <5F21734C-C88E-4401-8EB4-811681A42E67@gmail.com> References: <5F21734C-C88E-4401-8EB4-811681A42E67@gmail.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: CEA LIST Date: Thu, 12 Mar 2009 08:55:49 +0100 Message-Id: <1236844549.22473.184.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-OriginalArrivalTime: 12 Mar 2009 07:55:32.0503 (UTC) FILETIME=[EB443270:01C9A2E7] X-Spam: no; 0.00; signoles:01 signoles:01 mutable:01 struct:01 hash:01 hashtbl:01 hash:01 struct:01 pervasives:01 printf:01 foo:01 foo:01 graph:01 caml-list:01 cea:01 Hello, > It looks like the only way to change a label on an edge e -- say > increment it -- is to read off the old one with G.E.label, then > remember the src and dst with G.E.src/dst, then G.remove_edge_e g e, > create a new edge e' with G.V.create src (label+1) dst, and > G.add_adge_e g e'. Is this supposed to be so complicated even for the > imperative graphs? No it is not :-). You just have to define yourself a mutable label. Here is an example. ========== open Graph module G = Imperative.Digraph.ConcreteLabeled (struct include String let equal = (=) let hash = Hashtbl.hash end) (struct type t = int ref let default = ref 0 let compare = Pervasives.compare end) let g = G.create () let print_edge v1 v2 = Format.printf "edge = %d@." !(G.E.label (G.find_edge g v1 v2)) let e = G.E.create "foo" (ref 1) "bar" let () = G.add_edge_e g e; print_edge "foo" "bar"; G.E.label e := 2; print_edge "foo" "bar" ========== Hope this helps, Julien Signoles