graph

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package graph and sub-packages contain a virtual representation of a graph of connected networks and nodes. Utilities to simulate these virtual graphs exist in other packages in this repo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge = graph.Edge

Edge is the base type for an edge in the graph.

type FactoryAdder

type FactoryAdder func(b bus.Bus, sr *static.Resolver)

FactoryAdder is a adder for a factory.

type FactoryCtor

type FactoryCtor func(bus.Bus) controller.Factory

FactoryCtor is a constructor for a factory.

type Graph

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

Graph is an instance of a graph of connected nodes.

func NewGraph

func NewGraph() *Graph

NewGraph constructs a new network graph.

func (*Graph) AddEdge

func (g *Graph) AddEdge(edge Edge)

AddEdge adds an edge to the network graph.

func (*Graph) AddNode

func (g *Graph) AddNode(node Node)

AddNode adds a node to the network graph.

func (*Graph) AllEdges

func (g *Graph) AllEdges() []Edge

AllEdges returns the set of all edges in the graph.

func (*Graph) AllNodes

func (g *Graph) AllNodes() []Node

AllNodes returns the set of all nodes in the graph.

func (*Graph) AllPeers

func (g *Graph) AllPeers() []*Peer

AllPeers returns the set of all peers in the graph.

func (*Graph) BuildEdge

func (g *Graph) BuildEdge(from, to graph.Node) graph.Edge

BuildEdge constructs a new edge between two nodes.

func (*Graph) BuildNode

func (g *Graph) BuildNode() Node

BuildNode constructs a new base node.

func (*Graph) From

func (g *Graph) From(node Node) graph.Nodes

From returns all nodes that can be reached directly from the node.

func (*Graph) FromNodes

func (g *Graph) FromNodes(node Node) []Node

FromNodes returns From as a []Node.

func (*Graph) ShortestPath

func (g *Graph) ShortestPath(n1, n2 Node) []Node

ShortestPath finds the shortest path between the two nodes. Returns 0 len slice if not found.

func (*Graph) Subgraph

func (g *Graph) Subgraph(node Node) []graph.Node

Subgraph returns all nodes that are in the subgraph containing the node.

type LAN

type LAN struct {
	Node
}

LAN connects together machines and networks with implied many-to-many links. This simulates a wireless network, for example.

func AddLAN

func AddLAN(g *Graph) *LAN

AddLAN adds a lan to the network graph.

func (*LAN) AddConnectionToLAN

func (l *LAN) AddConnectionToLAN(g *Graph, ol *LAN) Edge

AddConnectionToLAN adds a connection to another lan.

func (*LAN) AddPeer

func (l *LAN) AddPeer(g *Graph, p *Peer) Edge

AddPeer adds a peer to the LAN.

func (*LAN) GetAssociatedPeers

func (l *LAN) GetAssociatedPeers(g *Graph) []*Peer

GetAssociatedPeers returns all peers directly linked to the lan.

type Node

type Node = graph.Node

Node is the base type for a node in the graph.

type Peer

type Peer struct {
	Node
	// contains filtered or unexported fields
}

Peer is a participating peer in the network. This corresponds to a controller bus and an inproc transport.

func AddPeer

func AddPeer(g *Graph, peerPriv crypto.PrivKey) (*Peer, error)

AddPeer adds a peer to the network graph.

func GenerateAddPeer

func GenerateAddPeer(ctx context.Context, g *Graph) (*Peer, error)

GenerateAddPeer generates a peer private key and adds it.

func (*Peer) AddConfig

func (p *Peer) AddConfig(id string, conf config.Config)

AddConfig adds a controller configuration to the peer.

func (*Peer) AddControllerConfig

func (p *Peer) AddControllerConfig(id string, conf configset.ControllerConfig)

AddControllerConfig adds a controller configuration to the peer.

func (*Peer) AddFactory

func (p *Peer) AddFactory(ct FactoryCtor)

AddFactory adds a factory constructor to the set.

func (*Peer) AddFactoryAdder

func (p *Peer) AddFactoryAdder(ct FactoryAdder)

AddFactoryAdder adds a factory adder to the set.

func (*Peer) DeleteConfig

func (p *Peer) DeleteConfig(id string)

DeleteConfig removes a configuration from the configset with id.

func (*Peer) GetConfigSet

func (p *Peer) GetConfigSet() configset.ConfigSet

GetConfigSet returns the extra controllers config set.

func (*Peer) GetExtraFactories

func (p *Peer) GetExtraFactories() []FactoryCtor

GetExtraFactories returns the slice of extra factories.

func (*Peer) GetExtraFactoryAdders

func (p *Peer) GetExtraFactoryAdders() []FactoryAdder

GetExtraFactoryAdders returns the slice of extra factory adders.

func (*Peer) GetLinkedPeers

func (p *Peer) GetLinkedPeers(g *Graph) []*Peer

GetLinkedPeers returns all peers that should have a link with the peer. This includes other peers directly linked as well as those linked by a lan or multiple lans.

func (*Peer) GetPeerID

func (p *Peer) GetPeerID() peer.ID

GetPeerID returns the peer ID.

func (*Peer) GetPeerPriv

func (p *Peer) GetPeerPriv() crypto.PrivKey

GetPeerPriv returns the peer private key.

func (*Peer) MergeConfigSet

func (p *Peer) MergeConfigSet(other configset.ConfigSet)

MergeConfigSet merges in a configset to the extra controllers set.

Jump to

Keyboard shortcuts

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