anchor.diff:      end.
   
   %% @doc Get the tail of the process that contracted a path.
  --spec get_process_tail(contract_process_id(), optimized_map()) -> lasp_vertex().
  +-spec get_process_tail(process_hash(), optimized_map()) -> lasp_vertex().
   get_process_tail(Id, OptMap) ->
       {_, [Tail | _], _} = dict:fetch(Id, OptMap),
       Tail.
  
positive.code: %% lets us quickly delete those edges.
  -type process_map() :: dict:dict(pid(), {id(), id()}).
  
  %% Stored metadata for a lasp process.
  %% We don't store the input(s) and output vertices as that information
  %% is implicitly stored by edges in the graph.
  -record(process_metadata, {read :: function(),
                             transform :: function(),
                             write :: function()}).
  
  %% We store a mapping Id -> {Pid, Path, MetadataList} to identify the list of
  %% vertices and relationships that get removed as part of a path contraction.
  %%
  %% Used during the cleaving step.
  -type contract_process_id() :: non_neg_integer().
  -type pid_table() :: dict:dict(pid(), contract_process_id()).
  -type optimized_map() :: dict:dict(contract_process_id(),
                                     {pid(),
                                      contract_path(),
                                      list(#process_metadata{})}).
  
  -record(state, {dag :: digraph:graph(),
                  process_map :: process_map(),
                  optimized_map :: optimized_map(),
                  pid_table :: pid_table(),
                  contraction_step :: non_neg_integer()}).
  
  %% We store the function metadata as the edge label.
  -record(edge_label, {pid :: pid(),
                      read :: function(),
                      transform :: function(),
                      write :: function()}).
  
  %% @todo Move somewhere else
  %% A tuple of the arguments of a lasp process.
  -type process_args() :: {[{lasp_vertex(), function()}],
                           function(),
                           {lasp_vertex(), function()}}.
  
  -record(vertex_label, {process_pointer :: contract_process_id()}).
  
  -type lasp_vertex() :: id() | pid().
  
  %% Return type of digraph:edge/2
  
negative.code:                       digraph:vertex(),
                        #edge_label{}}.
  
  %%%===================================================================
  %%% API
  %%%===================================================================
  