Module View.Make

Parameters

Signature

type t
type nid
type node
val empty : t

empty is the empty view.

val add : node -> t -> t

add node t adds node to view t

val remove : nid -> t -> t

remove node t removes node from view t

val length : t -> int

lengh t returns the number of nodes in view t

val is_empty : t -> bool

is_empty t returns true if there are no nodes in view t

val mem : nid -> t -> bool

mem nid t returns true if nid is in view t.

val find : nid -> t -> node option

find nid t returns Some node if nid is in view t, otherwise None.

val oldest : t -> node option

oldest t returns the oldest node in view. In case there are multiple oldest nodes, picks a random one of those.

val random : t -> node option

random t selects a random from view t. Returns None if t is empty.

val uniform_sample : int -> t -> t

uniform_sample n t returns a uniform random sample of view t of length n.

val weighted_sample : int -> t -> t

weighted_sample n t returns a weighted random sample of view t of length n, weighted by their trust values.

val union : t -> t -> t

union a b returns the union of views a & b.

val zero_age : t -> t

zero_age t sets the age of all nodes in view to 0.

val inc_age : t -> t

inc_age t increments the age of all nodes in view.

val adjust_trust : float -> t -> t

adjust_trust r t adjust the trust value of all nodes in t by multiplying each with r.

val filter_trust : float -> t -> t

filter_trust min_trust t remove nodes with trust value less than min_trust

val filter_overlap : t -> t -> t

filter_overlap view t remove entries from t that also exist in view

val min_trust : t -> float

min_trust t returns the minimum trust value in t

val max_trust : t -> float

max_trust t returns the maximum trust value in t

val sum_trust : t -> float

sum_trust t returns the sum of trust values in t

val choose_view : t -> t -> t

choose_view t u chooses a view at random from two views

val filter : (nid -> node -> bool) -> t -> t
val fold : (nid -> node -> 'a -> 'a) -> t -> 'a -> 'a
val iter : (nid -> node -> unit) -> t -> unit
val map : (nid -> node -> node) -> t -> t
val to_list : t -> node list
val of_list : node list -> t
val pp : Stdlib.Format.formatter -> t -> unit

pp ppf t pretty-prints view t