ontometer_corpus.network.hyperbolic¶
A radial layout of the ontology specialisation network in the Poincaré disk.
A drawing, not a learned embedding. Each ontology gets a fixed angle from a radial tree over the network at capture, so that it never moves sideways as time passes, and a radius from how much it is specialised at a given time, so that it moves inward exactly when it gains a specialiser.
- The tree is each ontology's primary parent — the ontology whose classes it specialises most — with cycles cut. Every root gets a wedge of the circle proportional to its subtree, roots are ordered by group (a community), and a node's children share its wedge in proportion to their own subtrees.
- The radius is a hyperbolic distance from the centre,
r = r_max * (1 - log(1 + s) / log(n))forstransitive specialisers, mapped to the disk astanh(r / 2), withna fixed normaliser — one more than the largestsat capture puts the most specialised ontology at the centre. An ontology nothing specialises sits near the rim, and a fixednkeeps each ontology's radius monotone in time.
Attributes¶
DEFAULT_R_MAX = 2.0 * math.atanh(0.95)
module-attribute
¶
Functions:¶
primary_parents(n, child, parent, weight)
¶
The parent each node specialises most, or -1; cycles are cut.
Ties go to the lower parent index. A cycle in the chosen pointers — two ontologies specialising each other most — is broken by making its lowest-index member a root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
number of nodes; indices run 0..n-1. |
required |
child
|
ndarray
|
child node of each edge. |
required |
parent
|
ndarray
|
parent node of each edge. |
required |
weight
|
ndarray
|
weight of each edge (e.g. the number of term-level specialisations behind it); self-loops are ignored. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The primary parent per node, -1 for a root. |
Source code in ontometer_corpus/network/hyperbolic.py
radial_angles(primary_parent, group)
¶
Angle in [0, 2π) per node from a radial tree over primary_parent.
Roots are ordered by group and then by subtree size, largest first;
each takes a wedge proportional to its subtree and is drawn at the
wedge's centre, and its children split the wedge the same way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary_parent
|
ndarray
|
parent per node, -1 for a root; must be acyclic (as
:func: |
required |
group
|
ndarray
|
integer group per node (e.g. a community); only roots' groups are used, to order them around the circle. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The angle per node, in radians. |
Source code in ontometer_corpus/network/hyperbolic.py
poincare_radius(specialisers, n, r_max=DEFAULT_R_MAX)
¶
Disk radius for specialisers transitive specialisers, normalised by n.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specialisers
|
ndarray
|
number of transitive specialisers per node. |
required |
n
|
int
|
the normaliser; a node with |
required |
r_max
|
float
|
hyperbolic radius of a node with no specialiser. |
DEFAULT_R_MAX
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The Euclidean radius in the unit disk, |