Coccinelle release 0.2.5-rc3
[bpt/coccinelle.git] / commons / ograph_extended.mli
CommitLineData
34e49164
C
1open Common
2
3type nodei = int
4
ae4735db
C
5(* graph structure:
6 * - node: index -> nodevalue
34e49164 7 * - arc: (index * index) * edgevalue
ae4735db 8 *
34e49164 9 * How ? matrix ? but no growing array :(
ae4735db 10 *
34e49164
C
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
ae4735db 15 * no problem, can omit index.
34e49164
C
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
ae4735db 54val dfs_iter :
34e49164
C
55 nodei -> (nodei -> unit) -> ('node, 'edge) ograph_mutable -> unit
56
ae4735db
C
57val dfs_iter_with_path :
58 nodei -> (nodei -> nodei list -> unit) -> ('node, 'edge) ograph_mutable ->
34e49164
C
59 unit
60
ae4735db
C
61val print_ograph_mutable_generic :
62 ('node, 'edge) ograph_mutable ->
485bce71
C
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)) ->
ae4735db
C
66 output_file:filename ->
67 launch_gv:bool ->
485bce71
C
68 unit
69
34e49164 70
ae4735db
C
71val print_ograph_extended :
72 ('node * string, 'edge) ograph_extended ->
73 filename (* output file *) ->
74 bool (* launch gv ? *) ->
34e49164
C
75 unit
76
ae4735db
C
77val print_ograph_mutable :
78 ('node * string, 'edge) ograph_mutable ->
79 filename (* output file *) ->
80 bool (* launch gv ? *) ->
34e49164 81 unit