File: test_149.ml

package info (click to toggle)
ocamlgraph 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,624 kB
  • sloc: ml: 19,995; xml: 151; makefile: 14; sh: 1
file content (20 lines) | stat: -rw-r--r-- 416 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

(* Issue #149 *)

module G = Graph.Persistent.Digraph.Concrete(
  struct
    type t = string
    let compare = compare
    let hash = Hashtbl.hash
    let equal = (=)
  end)

let g0 = G.empty
let g1 = G.add_edge g0 "a" "b"
let g2 = G.add_edge g1 "a" "c"
let g  = G.add_edge g2 "c" "a"

module Topo = Graph.Topological.Make_stable(G)

let l = Topo.fold (fun v l -> v :: l) g []
let () = assert (l = ["b"; "c"; "a"])