agatha.construct.graph_util module

agatha.construct.graph_util.record_to_bipartite_edges(records, get_neighbor_keys_fn, get_source_key_fn=<function <lambda>>, bidirectional=True)

This function is responsible for extracting edges from records. For example, if you had a bag of records, each containing a set of terms, you might want to get the set of edges between records and terms.

Parameters
  • records (Bag) – The collection of records we wish to extract edges from.

  • get_neighbor_keys_fn (Callable[[Dict[str, Any]], Iterable[str]]) – Given a record, return a list of graph keys that are adjacent to the given record

  • get_source_key_fn (Callable[[Dict[str, Any]], str]) – Given a record, return a graph key that uniquely identifies the root. By default we get the “id” field

  • bidirectional (bool) – If true, we write record->neighbor and neighbor->record. If false, we only write record->neighbor.

Return type

Bag

Returns

A bag containing serialized key-value pairs that can be used to create an Sqlite3LookupTable