Link graph (vaultkg.viz)¶
vaultkg.viz
¶
viz.py -- the vault's link graph as a self-contained interactive HTML page.
The renderer is kg_utils.viz.build_graph_html, shared with every other KG
module. What lives here is only what is about a vault: which kinds exist, how
relations are coloured, what a tooltip shows, and how notes are chosen when
the whole vault is too big to draw.
Notes are sized by backlinks (distinct notes linking in), so hubs stand out
without reading labels. pyvis arrives with the viz extra and is imported
by the SDK inside the render call; the CLI imports this module inside its
command, so a bare install never pulls it.
backlink_scores(kg)
¶
Distinct notes linking in, per note, as a score set for node sizing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg
|
VaultKG
|
An open vault graph. |
required |
Returns:
| Type | Description |
|---|---|
ScoreSet
|
A |
Source code in src/vaultkg/viz.py
112 113 114 115 116 117 118 119 120 121 122 | |
link_graph_html(kg, *, root=None, hops=1, max_nodes=200, kinds=DEFAULT_KINDS, height='800px', edge_labels=False)
¶
Render the vault's link graph as a self-contained HTML page.
With root, the picture is that note's neighbourhood, hops links
out in either direction. Without one it is the most connected part of the
vault: nodes ranked by how many edges touch them, cut at max_nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kg
|
VaultKG
|
An open vault graph. |
required |
root
|
str | None
|
A node id or a note's vault path to centre on, or |
None
|
hops
|
int
|
Links to expand from |
1
|
max_nodes
|
int
|
Node budget. |
200
|
kinds
|
tuple[str, ...]
|
Node kinds to draw; the root is drawn whatever its kind. |
DEFAULT_KINDS
|
height
|
str
|
CSS height of the canvas. |
'800px'
|
edge_labels
|
bool
|
Print each link's relation on the canvas. Off by
default: in a note's neighbourhood nearly every edge is |
False
|
Returns:
| Type | Description |
|---|---|
tuple[str, int, int]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/vaultkg/viz.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
vault_theme(relations, folders=None)
¶
The visual vocabulary for a vault.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relations
|
list[str]
|
Relations present in the graph; typed ones not in
:data: |
required |
folders
|
list[str] | None
|
Top-level folders, most notes first. Notes are coloured
by folder, matching the 3-D tree; |
None
|
Returns:
| Type | Description |
|---|---|
GraphTheme
|
A :class: |
Source code in src/vaultkg/viz.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |