From: Matthieu Wipliez <mwipliez@yahoo.fr>
To: OCaml <caml-list@inria.fr>
Subject: Re : [Caml-list] changing labels on ocamlgraph edges
Date: Thu, 12 Mar 2009 12:47:29 +0000 (GMT) [thread overview]
Message-ID: <366870.61081.qm@web27007.mail.ukl.yahoo.com> (raw)
In-Reply-To: <1236844549.22473.184.camel@localhost>
> 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)
I'm also using ocamlgraph with labels of type t = bool ref * int option
And I found that for add_edge to have the proper behavior, I need to replace the default add_edge with this one:
let add_edge graph v1 v2 = add_edge_e graph (v1, (ref false, None), v2)
Otherwise all edges share the same reference (created in "default"), and changing the boolean for an edge changes it for all edges...
Cheers,
Matthieu
>
> 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
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
next prev parent reply other threads:[~2009-03-12 12:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 1:47 Alexy Khrabrov
2009-03-12 7:55 ` [Caml-list] " Julien SIGNOLES
2009-03-12 12:47 ` Matthieu Wipliez [this message]
2009-03-12 14:38 ` Re : " Jean-Christophe Filliatre
2009-03-13 0:10 ` Alexy Khrabrov
2009-03-13 10:53 ` Re : " Matthieu Wipliez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=366870.61081.qm@web27007.mail.ukl.yahoo.com \
--to=mwipliez@yahoo.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox