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
EdgeFeature
Provides access to (edge) feature data.
Attributes
| Name | Type | Description |
|---|---|---|
| _data | — | — |
| _dataInv | — | — |
| _is_mmap | — | — |
| _none_sentinel | — | — |
| api | — | — |
| data | dict[(int, set[int] | dict[(int, Any)])] | Get forward edge data. |
| dataInv | dict[(int, set[int] | dict[(int, Any)])] | Get inverse edge data. |
| doValues | — | — |
| meta | — | Metadata 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) → NoneParameters
api: ApimetaData: dict[(str, Any)]data: dict[(int, set[int] | dict[(int, Any)])] | CSRArray | CSRArrayWithValues | tuple[(Any, Any)]doValues: booldataInv: 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)], ...)] | intFrequency list of the values of this feature.
Parameters
nodeTypesFrom: set[str] | None= NonenodeTypesTo: 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