graph

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package graph builds the memory graph the widget renders.

It never returns the whole vault. The graph view is ego-mode only — a focus node and its neighbourhood out to a few hops — because the full-graph hairball is a screenshot, not a tool: impressive once, useless every time after. The backend's job is to extract that neighbourhood, tag each edge with where it came from (so the UI can render trust), and, on request, add the view-time similarity edges that are computed from vectors already in the index and never written to disk.

Index

Constants

View Source
const SimilarityThreshold = 0.62

SimilarityThreshold is how close two notes must be to draw a lens edge between them. High on purpose — similarity edges are suggestive, and a low bar turns the graph into a cobweb where everything faintly touches everything.

Variables

This section is empty.

Functions

func DefaultFocus

func DefaultFocus(db *sql.DB, todaySlug string) string

DefaultFocus picks where to open the graph: today's daily note if it exists, otherwise the highest-degree node — the natural centre of what you know.

func Find

func Find(db *sql.DB, query string) (string, bool)

Find looks up a node by fuzzy title/slug match, for the "/" jump-to box.

Types

type Edge

type Edge struct {
	Src        string     `json:"src"`
	Dst        string     `json:"dst"`
	Pred       string     `json:"pred"`
	Conf       float64    `json:"conf"`
	Provenance Provenance `json:"provenance"`
}

type Graph

type Graph struct {
	Focus string `json:"focus"`
	Nodes []Node `json:"nodes"`
	Edges []Edge `json:"edges"`
}

func Ego

func Ego(db *sql.DB, focus string, hops int, withSimilarity bool) (Graph, error)

Ego returns the neighbourhood within `hops` of focus. Both directions of each edge are followed — a note you are linked *from* is as much a neighbour as one you link *to*.

type Node

type Node struct {
	Slug      string `json:"slug"`
	Title     string `json:"title"`
	Kind      string `json:"kind"`
	Degree    int    `json:"degree"`
	FirstSeen int64  `json:"first_seen"`
	// Hops is the distance from the focus node, 0 for the focus itself. The UI
	// dims outer rings so the eye starts at the centre.
	Hops int `json:"hops"`
}

type Provenance

type Provenance string

Provenance is where an edge came from — the thing that decides how much a viewer should trust it, and therefore how it is drawn.

const (
	// Wikilink: a [[link]] you typed. Absolute; drawn solid at full opacity.
	Wikilink Provenance = "wikilink"
	// Typed: a frontmatter relation carrying an explicit confidence.
	Typed Provenance = "typed"
	// Similarity: embedding proximity, computed at view time. A lens, not a
	// fact — faint, off by default, never persisted.
	Similarity Provenance = "similarity"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL