grew_graph.mli 2.39 KB
Newer Older
bguillaum's avatar
bguillaum committed
1
open Grew_ast
2
open Grew_fs
pj2m's avatar
pj2m committed
3 4
open Grew_edge
open Grew_node
bguillaum's avatar
bguillaum committed
5
open Grew_utils
pj2m's avatar
pj2m committed
6
open Edge
bguillaum's avatar
bguillaum committed
7
open Grew_command
pj2m's avatar
pj2m committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

module Deco: sig
  type t = 
      { nodes: int list;
	edges: (int * Label.t * int) list;
      }
  val empty:t
end

module Graph : sig
  type t  = {
      map: Node.t IntMap.t; (* node description *)
      lub: int;             (* least upper bound *)
    }

23 24 25 26 27 28
  type gid = int

  type concat_item =
    | Feat of (gid * string)
    | String of string

pj2m's avatar
pj2m committed
29 30 31 32 33 34 35
  val empty: t

  val build:
      ?domain: Ast.domain -> 
      ?locals: Label.decl array -> 
      Ast.node list -> 
      Ast.edge list -> 
36
	(t * Id.table * (Id.t * Feature_structure.t) list )
pj2m's avatar
pj2m committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

  (* a type for extension of graph: a former graph exists: in grew the former is a positive pattern and an extension is a "without" *)
  type extention = {
      ext_map: Node.t IntMap.t; (* node description *)
      old_map: Node.t IntMap.t; (* a partial map on old nodes for edge "Old -> New" and/or for new constraints on old nodes "Old [...]" *) 	
    }

  val build_extention:
      ?domain: Ast.domain -> 
      ?locals: Label.decl array -> 
      Id.table ->
      Ast.node list -> 
      Ast.edge list -> 
	(extention * Id.table)

  val find: int -> t -> Node.t
bguillaum's avatar
bguillaum committed
53
  val to_gr: t -> string
54
  val to_dot: ?main_feat:string -> ?deco:Deco.t -> t -> string
pj2m's avatar
pj2m committed
55 56 57
  val to_dep: ?main_feat:string -> ?deco:Deco.t -> t -> string

  val add_edge : t -> int -> Edge.t -> int -> t option
58
  val del_edge : ?edge_ident: string -> Loc.t -> t -> int -> Edge.t -> int -> t
pj2m's avatar
pj2m committed
59 60 61 62
  val del_node : t -> int -> t

  val add_neighbour : Loc.t -> t -> int -> Edge.t -> (int * t) 
  val merge_node : Loc.t -> t -> int -> int -> t option
63 64 65

  val shift_in : Loc.t -> t -> int -> int -> t
  val shift_out : Loc.t -> t -> int -> int -> t
pj2m's avatar
pj2m committed
66 67
  val shift_edges : Loc.t -> t -> int -> int -> t

68 69 70 71
  (** [update_feat tar_id tar_feat_name concat_items] sets the feature of the node [tar_id] 
      with feature name [tar_feat_name] to be the contatenation of values described by the [concat_items].
      It returns both the new graph and the new feature value produced as the second element *)
  val update_feat : t -> int -> string -> concat_item list -> (t * string)
pj2m's avatar
pj2m committed
72 73 74 75 76

  val del_feat : t -> int -> string -> t

  val equals : t -> t -> bool

bguillaum's avatar
bguillaum committed
77
  (** [edge_out t id edge] returns true iff there is an out-edge from the node [id] with a label compatible with [edge] *)
pj2m's avatar
pj2m committed
78 79 80 81 82
  val edge_out: t -> int -> Edge.t -> bool

  val roots: t -> int list
end