package forester

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file Forest_graph.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(*
 * SPDX-FileCopyrightText: 2024 The Forester Project Contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *)

module G = Graph.Imperative.Digraph.ConcreteBidirectional(Vertex)
include G
include Graph.Oper.I(G)
module Map = Graph.Gmap.Vertex(G)

module Reachability = Graph.Fixpoint.Make(G)(struct
  type vertex = G.E.vertex
  type edge = G.E.t
  type g = G.t
  type data = bool
  let direction = Graph.Fixpoint.Forward
  let equal = (=)
  let join = (||)
  let analyze _ = (fun x -> x)
end)

module Topo = Graph.Topological.Make(G)
let topo_fold = Topo.fold
let topo_iter = Topo.iter

let safe_succ g x =
  if mem_vertex g x then succ g x else []

let safe_dependents = safe_succ

let safe_pred g x =
  if mem_vertex g x then pred g x else []

let immediate_dependencies = safe_pred

let dependencies graph vertex : t =
  let dep_graph = create () in
  let rec go v =
    iter_pred
      (fun dep ->
        if mem_vertex dep_graph dep then ()
        else
          begin
            add_edge dep_graph dep v;
            go dep
          end
      )
      graph
      v
  in
  go vertex;
  dep_graph

module Graphviz = Graph.Graphviz.Dot(struct
  include G
  module V = Vertex

  let vertex_name v =
    match Vertex.uri_of_vertex v with
    | Some uri -> "\"" ^ URI.to_string uri ^ "\""
    | None -> ""

  let graph_attributes _ = []
  let default_vertex_attributes _ = []
  let vertex_attributes _ = []
  let default_edge_attributes _ = []
  let edge_attributes _e = [`Label ""]
  let get_subgraph _ = None
end)
OCaml

Innovation. Community. Security.