simple

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package simple holds a very simple graph structure suitable to receive an onnx model

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrderedChildren

func GetOrderedChildren(g graph.WeightedDirected, n graph.Node) *iterator.OrderedNodes

GetOrderedChildren returns an iterator of children nodes ordered by the weighted edges

Types

type Graph

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

Graph is a simple directed graph

func NewSimpleGraph

func NewSimpleGraph() *Graph

NewSimpleGraph ...

func (*Graph) AddNode

func (g *Graph) AddNode(n graph.Node)

AddNode adds n to the graph. It panics if the added node ID matches an existing node ID.

func (*Graph) ApplyOperation

func (g *Graph) ApplyOperation(_ onnx.Operation, _ ...graph.Node) error

ApplyOperation to fulfil the OperationCarrier interface

func (*Graph) DOTAttributers

func (g *Graph) DOTAttributers() (graph, node, edge encoding.Attributer)

DOTAttributers is used for representation in graphviz

func (*Graph) Edge

func (g *Graph) Edge(uid, vid int64) graph.Edge

Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.

func (*Graph) From

func (g *Graph) From(id int64) graph.Nodes

From returns all nodes in g that can be reached directly from n.

func (*Graph) HasEdgeBetween

func (g *Graph) HasEdgeBetween(xid, yid int64) bool

HasEdgeBetween returns whether an edge exists between nodes x and y without considering direction.

func (*Graph) HasEdgeFromTo

func (g *Graph) HasEdgeFromTo(uid, vid int64) bool

HasEdgeFromTo returns whether an edge exists in the graph from u to v.

func (*Graph) NewNode

func (g *Graph) NewNode() graph.Node

NewNode returns a new unique Node to be added to g. The Node's ID does not become valid in g until the Node is added to g.

func (*Graph) NewWeightedEdge

func (g *Graph) NewWeightedEdge(from, to graph.Node, w float64) graph.WeightedEdge

NewWeightedEdge returns a new weighted edge from the source to the destination node.

func (*Graph) Node

func (g *Graph) Node(id int64) graph.Node

Node returns the node with the given ID if it exists in the graph, and nil otherwise.

func (*Graph) Nodes

func (g *Graph) Nodes() graph.Nodes

Nodes returns all the nodes in the graph.

func (*Graph) SetWeightedEdge

func (g *Graph) SetWeightedEdge(e graph.WeightedEdge)

SetWeightedEdge adds a weighted edge from one node to another. If the nodes do not exist, they are added and are set to the nodes of the edge otherwise. It will panic if the IDs of the e.From and e.To are equal.

func (*Graph) To

func (g *Graph) To(id int64) graph.Nodes

To returns all nodes in g that can reach directly to n.

type Node

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

Node of the graph

func (*Node) ApplyTensor

func (n *Node) ApplyTensor(t tensor.Tensor) error

ApplyTensor to fulfil the TensorCarrier interface

func (*Node) Attributes

func (n *Node) Attributes() []encoding.Attribute

Attributes it a method to fulfil the encoding/dot package

func (*Node) GetDescription

func (n *Node) GetDescription() string

GetDescription to fulfil the Namer interface

func (*Node) GetName

func (n *Node) GetName() string

GetName to fulfil the Namer interface

func (*Node) ID

func (n *Node) ID() int64

ID to fulfil the graph.Node interface

func (*Node) SetDescription

func (n *Node) SetDescription(desc string)

SetDescription to fulfil the Namer interface

func (*Node) SetName

func (n *Node) SetName(desc string)

SetName to fulfil the Namer interface

Jump to

Keyboard shortcuts

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