graph

package
v2.0.0-...-42b7f86 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Loaded = (*Graph)(nil)

Functions

func CreateNode

func CreateNode(fileName string, node *Node) error

func UpdateNode

func UpdateNode(fileName string, node *Node) error

func WriteNode

func WriteNode(fileName string, node *Node, update bool) error

Types

type Edge

type Edge struct {
	Type      EdgeType     `json:"type"`
	CreatedAt time.Time    `json:"created_at"`
	Position  *session.GPS `json:"position,omitempty"`
}

func (Edge) Dot

func (e Edge) Dot(left, right *Node, width float64) string

type EdgeCallback

type EdgeCallback func(*Node, []Edge, *Node)

type EdgeEvent

type EdgeEvent struct {
	Left  *Node
	Edge  *Edge
	Right *Node
}

type EdgeType

type EdgeType string
const (
	Is         EdgeType = "is"
	ProbesFor  EdgeType = "probes_for"
	ProbedBy   EdgeType = "probed_by"
	ConnectsTo EdgeType = "connects_to"
	Manages    EdgeType = "manages"
)

type Edges

type Edges struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func LoadEdges

func LoadEdges(basePath string) (*Edges, error)

func (*Edges) Connect

func (e *Edges) Connect(fromID, toID string, edge Edge) error

func (*Edges) FindEdges

func (e *Edges) FindEdges(fromID, toID string, doSort bool) []Edge

func (*Edges) Flush

func (e *Edges) Flush() error

func (*Edges) ForEachEdge

func (e *Edges) ForEachEdge(cb EdgesCallback) error

func (*Edges) ForEachEdgeFrom

func (e *Edges) ForEachEdgeFrom(nodeID string, cb EdgesCallback) error

func (*Edges) IsConnected

func (e *Edges) IsConnected(nodeID string) bool

type EdgesCallback

type EdgesCallback func(string, []Edge, string) error

type EdgesTo

type EdgesTo map[string][]Edge

type Graph

type Graph struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(path string) (*Graph, error)

func (*Graph) CreateEdge

func (g *Graph) CreateEdge(from, to *Node, edgeType EdgeType) (*Edge, error)

func (*Graph) CreateNode

func (g *Graph) CreateNode(t NodeType, id string, entity interface{}, annotations string) (*Node, error)

func (*Graph) Dot

func (g *Graph) Dot(filter, layout, name string, disconnected bool) (string, int, int, error)

func (*Graph) EachEdge

func (g *Graph) EachEdge(cb EdgeCallback) error

func (*Graph) EachNode

func (g *Graph) EachNode(cb NodeCallback) error

func (*Graph) FindLastEdgeOfType

func (g *Graph) FindLastEdgeOfType(from, to *Node, edgeType EdgeType) (*Edge, error)

func (*Graph) FindLastRecentEdgeOfType

func (g *Graph) FindLastRecentEdgeOfType(from, to *Node, edgeType EdgeType, staleTime time.Duration) (*Edge, error)

func (*Graph) FindNode

func (g *Graph) FindNode(t NodeType, id string) (*Node, error)

func (*Graph) FindOtherTypes

func (g *Graph) FindOtherTypes(t NodeType, id string) ([]*Node, error)

func (*Graph) IsConnected

func (g *Graph) IsConnected(nodeType string, nodeID string) bool

func (*Graph) JSON

func (g *Graph) JSON(filter string, disconnected bool) (string, int, int, error)

func (*Graph) Traverse

func (g *Graph) Traverse(root string, onNode NodeCallback, onEdge EdgeCallback) error

func (*Graph) UpdateNode

func (g *Graph) UpdateNode(node *Node) error

type Module

type Module struct {
	session.SessionModule
	// contains filtered or unexported fields
}

func NewModule

func NewModule(s *session.Session) *Module

func (*Module) Author

func (mod *Module) Author() string

func (*Module) Configure

func (mod *Module) Configure() (err error)

func (*Module) Description

func (mod *Module) Description() string

func (*Module) Name

func (mod *Module) Name() string

func (*Module) Start

func (mod *Module) Start() error

func (*Module) Stop

func (mod *Module) Stop() error

type Node

type Node struct {
	Type        NodeType    `json:"type"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
	ID          string      `json:"id"`
	Annotations string      `json:"annotations"`
	Entity      interface{} `json:"entity"`
	Dummy       bool        `json:"-"`
}

func ReadNode

func ReadNode(fileName string) (*Node, error)

func (Node) Dot

func (n Node) Dot(isTarget bool) string

func (Node) Label

func (n Node) Label() string

func (Node) String

func (n Node) String() string

func (Node) ToMap

func (n Node) ToMap() (map[string]interface{}, error)

type NodeCallback

type NodeCallback func(*Node)

type NodeType

type NodeType string
const (
	SSID        NodeType = "ssid"
	BLEServer   NodeType = "ble_server"
	Station     NodeType = "station"
	AccessPoint NodeType = "access_point"
	Endpoint    NodeType = "endpoint"
	Gateway     NodeType = "gateway"
)

type Stack

type Stack struct {
	Size int
	// contains filtered or unexported fields
}

func NewStack

func NewStack() *Stack

func (*Stack) Pop

func (stk *Stack) Pop() interface{}

func (*Stack) Push

func (stk *Stack) Push(data interface{})

Jump to

Keyboard shortcuts

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