Documentation

edge

Mappings from edges to values.

Every edge feature is logically a mapping from pairs of nodes to values, string or integer.

A feature object gives you methods that you can pass a node and that returns its value for that node.

It is easiest to think of all edge features as a dictionary keyed by nodes. The values are either sets or dictionaries. If the value is a set, then the elements are the second node in the pair and the value is `None`. If the value is a dictionary, then the keys are the second node in the pair, and the value is the value that the edge feature assigns to this pair.

However, some features have an optimised representation, and do not have a dictionary underneath.

But you can still iterate over the data of a feature as if it were a dictionary: `cfabric.edgefeature.EdgeFeature.items`

This module supports two storage backends: - Dict-based storage (.tf loading): dict[int, set|dict] - CSR mmap-based storage (.cfm loading): CSRArray or CSRArrayWithValues

Classes

class

EdgeFeature

Provides access to (edge) feature data.

Provides access to (edge) feature data. For feature `fff` it is the result of `E.fff` or `Es('fff')`. This class supports two storage backends: - Dict-based (.tf loading): dict[int, set|dict] - Mmap (.cfm loading): CSRArray or CSRArrayWithValues for memory-mapped access The backend is auto-detected based on the data type passed to __init__.

Attributes

NameTypeDescription
_data
_dataInv
_is_mmap
_none_sentinel
api
datadict[(int, set[int] | dict[(int, Any)])]Get forward edge data.
dataInvdict[(int, set[int] | dict[(int, Any)])]Get inverse edge data.
doValues
metaMetadata of the feature.

Methods

__init__(self, api: Api, metaData: dict[(str, Any)], data: dict[(int, set[int] | dict[(int, Any)])] | CSRArray | CSRArrayWithValues | tuple[(Any, Any)], doValues: bool, dataInv: CSRArray | CSRArrayWithValues | None = None) None
Parameters
  • api: Api
  • metaData: dict[(str, Any)]
  • data: dict[(int, set[int] | dict[(int, Any)])] | CSRArray | CSRArrayWithValues | tuple[(Any, Any)]
  • doValues: bool
  • dataInv: CSRArray | CSRArrayWithValues | None= None
b(self, n: int) tuple[(int, ...)] | tuple[(tuple[(int, Any)], ...)]

Query *both* incoming edges to, and outgoing edges from a node.

Parameters
  • n: int
f(self, n: int) tuple[(int, ...)] | tuple[(tuple[(int, Any)], ...)]

Get outgoing edges *from* a node.

Parameters
  • n: int
freqList(self, nodeTypesFrom: set[str] | None = None, nodeTypesTo: set[str] | None = None) tuple[(tuple[(Any, int)], ...)] | int

Frequency list of the values of this feature.

Parameters
  • nodeTypesFrom: set[str] | None= None
  • nodeTypesTo: set[str] | None= None
items(self) Iterator[tuple[(int, set[int] | dict[(int, Any)])]]

A generator that yields the items of the feature, seen as a mapping.

t(self, n: int) tuple[(int, ...)] | tuple[(tuple[(int, Any)], ...)]

Get incoming edges *to* a node.

Parameters
  • n: int
class

EdgeFeatures