graphdb

package
v0.1.0-proto2i Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	From   string `json:"from"`
	To     string `json:"to"`
	Kind   string `json:"kind"`
	Weight int    `json:"weight"`
}

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph is backed by an in-memory bbolt database. Concurrency safety comes entirely from bbolt's transaction model: db.Update takes an exclusive write lock and db.View a read lock, and every exported operation goes through one of them. There is deliberately no additional outer mutex - a previous unused sync.Mutex field implied a locking strategy that was never actually applied.

func New

func New() (*Graph, error)

func (*Graph) AddEdge

func (g *Graph) AddEdge(e Edge) error

func (*Graph) AddNode

func (g *Graph) AddNode(n Node) error

func (*Graph) Close

func (g *Graph) Close() error

func (*Graph) GetStoredPath

func (g *Graph) GetStoredPath(start, end, kind string) (*Path, error)

func (*Graph) Neighbors

func (g *Graph) Neighbors(id string, kind string) ([]Edge, error)

func (*Graph) ShortestPath

func (g *Graph) ShortestPath(start, end, kind string, ttl int64) ([]string, int, error)

type Item

type Item struct {
	Node     string
	Cost     int
	Path     []string
	Priority int
	Index    int
}

type Node

type Node struct {
	ID     string            `json:"id"`
	Type   string            `json:"type"`
	Labels map[string]string `json:"labels"`
}

type Path

type Path struct {
	From      string   `json:"from"`
	To        string   `json:"to"`
	Kind      string   `json:"kind"`
	Nodes     []string `json:"nodes"`
	Cost      int      `json:"cost"`
	Timestamp int64    `json:"timestamp"`
	TTL       int64    `json:"ttl"`
}

type PriorityQueue

type PriorityQueue []*Item

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

Jump to

Keyboard shortcuts

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