Commit 59cc5987 authored by bguillaum's avatar bguillaum
Browse files

raw output

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/semagramme/libcaml-grew/trunk@7531 7838e531-6607-4d57-9587-6c381814729c
parent 27b0629a
......@@ -113,6 +113,8 @@ module G_fs = struct
(* list are supposed to be striclty ordered wrt compare*)
type t = G_feature.t list
let to_raw t = t
let empty = []
let set_feat ?loc feature_name atom t =
......
......@@ -29,6 +29,7 @@ module G_fs: sig
val to_dot: ?main_feat: string -> t -> string
val to_word: ?main_feat: string -> t -> string
val to_dep: ?main_feat: string -> t -> string
val to_raw: t -> (string * string) list
val to_string: t -> string
......@@ -54,6 +55,7 @@ module P_fs: sig
val to_dot: t -> string
exception Fail
(** [match_ ?param t gfs] tries to match the pattern fs [pfs] with the graph fs [gfs]
......
......@@ -223,6 +223,35 @@ module G_graph = struct
| (Gid.Old i,_) -> i
| _ -> Error.bug "[G_graph.max_binding]"
let list_search test =
let rec loop n = function
| [] -> raise Not_found
| x::_ when test x -> n
| _::t -> loop (n+1) t
in loop 0
let to_raw t =
let node_list = ref [] in
Gid_map.iter
(fun pid node ->
node_list := (pid, G_fs.to_raw (G_node.get_fs node)) :: !node_list
)
t;
let search pid = list_search (fun (x,_) -> x=pid) !node_list in
let edge_list = ref [] in
Gid_map.iter
(fun src_pid node ->
Massoc_gid.iter
(fun tar_pid edge ->
edge_list := (search src_pid, G_edge.to_string edge, search tar_pid) :: !edge_list
)
(G_node.get_next node)
)
t;
(List.map snd !node_list, !edge_list)
let equals t t' = Gid_map.equal (fun node1 node2 -> node1 = node2) t t'
(* is there an edge e out of node i ? *)
let edge_out graph node_id p_edge =
let node = Gid_map.find node_id graph.map in
......
......@@ -76,6 +76,8 @@ module G_graph: sig
[Not_found] is raised if [gid] is not defined in [graph]. *)
val find: Gid.t -> t -> G_node.t
val to_raw: t -> ((string * string) list list) * (int * string * int) list
val equals: t -> t -> bool
val node_exists: (G_node.t -> bool) -> t -> bool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment