locality
# Local navigation between nodes.
Classes
class
Locality
Methods by which you can navigate from a node to its neighbourhood.
Methods by which you can navigate from a node to its neighbourhood.
Neighbours are: nodes that have slots in common, embedders and embeddees,
previous and next siblings.
!!! note "L"
The Locality API is exposed as `L` or `Locality`.
!!! note "`otype` parameter"
In all of the following `L`-functions, if the `otype` parameter is passed,
the result is filtered and only nodes with
`otype=nodeType` or `otype in nodeTypes` are retained.
`otype` can be a string (a single node type) or a (frozen)set of node types.
!!! caution "Results of the `L.` functions are tuples, not single nodes"
Even if an `L`-function returns a single node, it is packed in a *tuple*.
So to get the node itself, you have to index the tuple:
L.u(node)[0]
!!! caution "Locality and node types"
When using `cfabric.nodes.Nodes.sortNodes` and the `L` methods,
note the following.
Suppose you have node types `verse` and `sentence`, and usually a
verse has multiple sentences, but not vice versa. Then you expect that
* `L.d(verseNode)` will contain sentence nodes,
* `L.d(sentenceNode)` will **not** contain verse nodes.
But if there is a verse with exactly one sentence, and both have exactly the
same words, then that is a case where:
* `L.d(verseNode)` will contain `sentenceNode`,
* `L.d(sentenceNode)` will contain `verseNode`.
Attributes
| Name | Type | Description |
|---|---|---|
| api | — | — |
Methods
__init__(self, api: Api) → NoneParameters
api: Api
d(self, n: int, otype: str | set[str] | frozenset[str] | None = None) → tuple[(int, ...)]Produces an ordered tuple of *downward* nodes.
Parameters
n: intotype: str | set[str] | frozenset[str] | None= None
i(self, n: int, otype: str | set[str] | frozenset[str] | None = None) → tuple[(int, ...)]Produces an ordered tuple of *intersecting* nodes
Parameters
n: intotype: str | set[str] | frozenset[str] | None= None
n(self, n: int, otype: str | set[str] | frozenset[str] | None = None) → tuple[(int, ...)]Produces an ordered tuple of *next* nodes.
Parameters
n: intotype: str | set[str] | frozenset[str] | None= None
p(self, n: int, otype: str | set[str] | frozenset[str] | None = None) → tuple[(int, ...)]Produces an ordered tuple of *previous* nodes.
Parameters
n: intotype: str | set[str] | frozenset[str] | None= None
u(self, n: int, otype: str | set[str] | frozenset[str] | None = None) → tuple[(int, ...)]Produces an ordered tuple of *upward* nodes.
Parameters
n: intotype: str | set[str] | frozenset[str] | None= None