Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Serializes graph from pfff to JSON (GraphSON) format #129

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -64,6 +64,10 @@ _darcs

Fig_graph_ml.pdf

# piqi_ddl_files
piqi_ddl_files/graph_graphson_piqi_ext.ml
piqi_ddl_files/graph_graphson_piqi.ml

# data
/TAGS
/DB_LIGHT
Expand Down
21 changes: 21 additions & 0 deletions Makefile
Expand Up @@ -142,6 +142,14 @@ LIBS= commons/lib.cma \
$(GRAPHCMA) \
$(EXTLIBCMA) $(PTCMA) $(ZIPCMA) $(JAVALIBCMA) \
commons/commons_features.cma \
external/optcomp-1.6/optcomp.cma \
external/xmlm-1.2.0/xmlm.cma \
external/ocaml-base64-1.1.0/base64.cma \
external/ulex-1.1/ulexing.cma \
external/easy-format-1.0.2/easy_format.cma \
external/piqi-0.6.10/piqilib/piqilib.cma \
external/piqi-ocaml/piqirun/piqirun.cma \
$(TOP)/piqi_ddl_files/lib.cma \
globals/lib.cma \
h_files-format/lib.cma \
h_version-control/lib.cma \
Expand Down Expand Up @@ -200,6 +208,14 @@ LIBS= commons/lib.cma \

MAKESUBDIRS=commons \
commons/graph \
external/optcomp-1.6 \
external/xmlm-1.2.0 \
external/ocaml-base64-1.1.0 \
external/ulex-1.1 \
external/easy-format-1.0.2 \
external/piqi-ocaml \
external/piqi-0.6.10/piqilib \
$(TOP)/piqi_ddl_files \
$(JSONDIR) \
$(GRAPHDIR) \
$(GUIDIR) $(CAIRODIR) \
Expand Down Expand Up @@ -262,6 +278,11 @@ MAKESUBDIRS=commons \

INCLUDEDIRS=$(MAKESUBDIRS) \
commons/ocamlextra commons/ocollection \
external/piqi-0.6.10/piqilib \
external/piqi-0.6.10/deps/base64 \
external/piqi-0.6.10/deps/ulex \
external/piqi-ocaml \
external/piqi-0.6.10 \
$(GTKINCLUDE) $(CAIROINCLUDE) \
$(OCAMLCOMPILERDIR)

Expand Down
16 changes: 15 additions & 1 deletion commons/common.ml
Expand Up @@ -704,7 +704,13 @@ let find_some p xs =

let rec find_opt f xs =
find_some_opt (fun x -> if f x then Some x else None) xs


let rec find_bool f = function
| [] -> false
| x :: l ->
match f x with
| false -> find_bool f l
| _ -> true

(*****************************************************************************)
(* Regexp, can also use PCRE *)
Expand Down Expand Up @@ -847,6 +853,14 @@ let write_file ~file s =
let chan = open_out file in
(output_string chan s; close_out chan)

let append_file ~file s =
let out = open_out_gen [Open_wronly; Open_append; Open_creat;
Open_text] 0o666 file in
(* Opens file and returns corresponding object *)
output_string out (s^"\n");
close_out out


(* could be in control section too *)

let filemtime file =
Expand Down
3 changes: 3 additions & 0 deletions commons/common.mli
Expand Up @@ -52,6 +52,7 @@ type path = string
val cat : filename -> string list

val write_file : file:filename -> string -> unit
val append_file : file:filename -> string -> unit
val read_file : filename -> string

val with_open_outfile :
Expand All @@ -75,6 +76,8 @@ val find_some : ('a -> 'b option) -> 'a list -> 'b
val find_some_opt : ('a -> 'b option) -> 'a list -> 'b option
val filter_some: 'a option list -> 'a list

val find_bool: ('a -> bool) -> 'a list -> bool

val take : int -> 'a list -> 'a list
val take_safe : int -> 'a list -> 'a list
val drop : int -> 'a list -> 'a list
Expand Down
12 changes: 12 additions & 0 deletions commons/graph/graph.ml
Expand Up @@ -314,6 +314,18 @@ let add_edge k1 k2 g =
(* Graph access *)
(*****************************************************************************)

let graph_og g =
g.og

let graph_key_of_vertex g =
g.key_of_vertex

let graph_vertex_of_key g =
g.vertex_of_key

let graph_cnt g =
g.cnt

let nodes g =
Common2.hkeys g.vertex_of_key

Expand Down
6 changes: 6 additions & 0 deletions commons/graph/graph.mli
Expand Up @@ -20,6 +20,12 @@ val copy:


(* graph access *)
(*module Ocamlgraph.Pack.Digraph = Ocamlgraph.Pack.Digraph*)

val graph_og: 'a graph -> Ocamlgraph.Pack.Digraph.t
val graph_key_of_vertex: 'a graph -> (Ocamlgraph.Pack.Digraph.V.t, 'a) Hashtbl.t
val graph_vertex_of_key: 'a graph -> ('a, Ocamlgraph.Pack.Digraph.V.t) Hashtbl.t
val graph_cnt: 'a graph -> int ref
val nodes: 'a graph -> 'a list
val succ: 'a -> 'a graph -> 'a list
val pred: 'a -> 'a graph -> 'a list (* slow! *)
Expand Down
3 changes: 3 additions & 0 deletions configure
Expand Up @@ -316,6 +316,9 @@ if($error || $error2) {
pr2 "!!Problems during ./configure!!";
}

system("echo \" piqi \"");
system("`pwd`/external/piqi-0.6.10/configure");

######################################################################
# Diagnostic
######################################################################
Expand Down