Release coccinelle-0.1.2
[bpt/coccinelle.git] / commons / ograph_extended.mli
CommitLineData
34e49164
C
1open Common
2
3type nodei = int
4
5(* graph structure:
6 * - node: index -> nodevalue
7 * - arc: (index * index) * edgevalue
8 *
9 * How ? matrix ? but no growing array :(
10 *
11 * When need index ? Must have an index when can't just use the nodevalue
12 * as a key, cos sometimes may have 2 times the same key, but it must
13 * be 2 different nodes. For instance in a C program 'f(); f();' we want 2
14 * nodes, one per 'f();' hence the index. If each node is different, then
15 * no problem, can omit index.
16 *)
17
18class ['node, 'edge] ograph_extended :
19object ('o)
20 method add_node : 'node -> 'o * nodei
21 method add_nodei : nodei -> 'node -> 'o * nodei
22 method replace_node : nodei * 'node -> 'o
23 method del_node : nodei -> 'o
24
25 method add_arc : (nodei * nodei) * 'edge -> 'o
26 method del_arc : (nodei * nodei) * 'edge -> 'o
27
28 method nodes : (nodei, 'node) Oassoc.oassoc
29
30 method successors : nodei -> (nodei * 'edge) Oset.oset
31 method predecessors : nodei -> (nodei * 'edge) Oset.oset
32 method allsuccessors : (nodei, (nodei * 'edge) Oset.oset) Oassoc.oassoc
33end
34
35
36class ['node, 'edge] ograph_mutable :
37object ('o)
38 method add_node : 'node -> nodei
39 method add_nodei : nodei -> 'node -> unit
40 method replace_node : nodei * 'node -> unit
41 method del_node : nodei -> unit
42
43 method add_arc : (nodei * nodei) * 'edge -> unit
44 method del_arc : (nodei * nodei) * 'edge -> unit
45
46 method nodes : (nodei, 'node) Oassoc.oassoc
47
48 method successors : nodei -> (nodei * 'edge) Oset.oset
49 method predecessors : nodei -> (nodei * 'edge) Oset.oset
50 method allsuccessors : (nodei, (nodei * 'edge) Oset.oset) Oassoc.oassoc
51end
52
53
54val dfs_iter :
55 nodei -> (nodei -> unit) -> ('node, 'edge) ograph_mutable -> unit
56
57val dfs_iter_with_path :
58 nodei -> (nodei -> nodei list -> unit) -> ('node, 'edge) ograph_mutable ->
59 unit
60
485bce71
C
61val print_ograph_mutable_generic :
62 ('node, 'edge) ograph_mutable ->
63 string option -> (* label for the entire graph *)
64 (* what string to print for a node and how to color it *)
65 ((nodei * 'node) -> (string * string option * string option)) ->
66 output_file:filename ->
67 launch_gv:bool ->
68 unit
69
34e49164
C
70
71val print_ograph_extended :
72 ('node * string, 'edge) ograph_extended ->
73 filename (* output file *) ->
74 bool (* launch gv ? *) ->
75 unit
76
77val print_ograph_mutable :
78 ('node * string, 'edge) ograph_mutable ->
79 filename (* output file *) ->
80 bool (* launch gv ? *) ->
81 unit