Documentation ¶
Index ¶
- type Attributes
- func (m Attributes) Copy() Attributes
- func (m Attributes) Del(key string)
- func (m Attributes) Exists(key string) bool
- func (m Attributes) Filter(filter func(key string, v interface{}) bool) Attributes
- func (m Attributes) Get(key string) interface{}
- func (m Attributes) GetBool(key string) bool
- func (m Attributes) GetInt(key string) int
- func (m Attributes) GetString(key string) string
- func (m Attributes) Range(iterator func(key string, v interface{}) bool)
- func (m Attributes) Set(k string, v interface{})
- func (m Attributes) SetAll(data map[string]interface{})
- type Edge
- type Export
- type Graph
- func (g *Graph) BFS(edgeType string, rootNode Path, fn func(nodePath Node) bool)
- func (g *Graph) Close()
- func (g *Graph) DFS(edgeType string, rootNode Path, fn func(nodePath Node) bool)
- func (g *Graph) DelEdge(id Path)
- func (g *Graph) DelNode(id Path)
- func (g *Graph) EdgeTypes() []string
- func (g *Graph) Export() *Export
- func (g *Graph) GetEdge(id Path) (Edge, bool)
- func (g *Graph) GetNode(id Path) (Node, bool)
- func (g *Graph) HasEdge(id Path) bool
- func (g *Graph) HasNode(id Path) bool
- func (g *Graph) Import(exp *Export) error
- func (g *Graph) NodeTypes() []string
- func (g *Graph) RangeEdges(edgeType string, fn func(e Edge) bool)
- func (g *Graph) RangeEdgesFrom(edgeType string, id Path, fn func(e Edge) bool)
- func (g *Graph) RangeEdgesTo(edgeType string, id Path, fn func(e Edge) bool)
- func (g *Graph) RangeNodes(nodeType string, fn func(n Node) bool)
- func (g *Graph) ReverseBFS(edgeType string, rootNode Path, fn func(nodePath Node) bool)
- func (g *Graph) ReverseDFS(edgeType string, rootNode Path, fn func(nodePath Node) bool)
- func (g *Graph) ReverseTopologicalSort(nodeType, edgeType string, fn func(node Node) bool)
- func (g *Graph) SetEdge(from, to Path, node Node) (Edge, error)
- func (g *Graph) SetNode(key Path, attr Attributes) Node
- func (g *Graph) TopologicalSort(nodeType, edgeType string, fn func(node Node) bool)
- type Node
- type Path
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attributes ¶ added in v0.14.0
type Attributes map[string]interface{}
func (Attributes) Copy ¶ added in v0.14.0
func (m Attributes) Copy() Attributes
Copy creates a replica of the Node
func (Attributes) Del ¶ added in v0.14.0
func (m Attributes) Del(key string)
Del deletes the entry from the Attributes by key
func (Attributes) Exists ¶ added in v0.14.0
func (m Attributes) Exists(key string) bool
Exists checks for the existance of a key
func (Attributes) Filter ¶ added in v0.14.0
func (m Attributes) Filter(filter func(key string, v interface{}) bool) Attributes
Filter returns a Attributes of the node that return true from the filter function
func (Attributes) Get ¶ added in v0.14.0
func (m Attributes) Get(key string) interface{}
Get gets an entry from the Attributes by key
func (Attributes) GetBool ¶ added in v0.14.0
func (m Attributes) GetBool(key string) bool
GetBool gets an entry from the Attributes by key
func (Attributes) GetInt ¶ added in v0.14.0
func (m Attributes) GetInt(key string) int
GetInt gets an entry from the Attributes by key
func (Attributes) GetString ¶ added in v0.14.0
func (m Attributes) GetString(key string) string
GetString gets an entry from the Attributes by key
func (Attributes) Range ¶ added in v0.14.0
func (m Attributes) Range(iterator func(key string, v interface{}) bool)
Range iterates over the Attributes with the function. If the function returns false, the iteration exits.
func (Attributes) Set ¶ added in v0.14.0
func (m Attributes) Set(k string, v interface{})
Set set an entry in the Node
func (Attributes) SetAll ¶ added in v0.14.0
func (m Attributes) SetAll(data map[string]interface{})
SetAll set all entries in the Node
type Edge ¶ added in v0.1.1
type Edge struct { // An edge implements Node because it has an Identifier and attributes Node `json:"node"` // From returns the root node of the edge From Path `json:"from"` // To returns the target node of the edge To Path `json:"to"` }
Edge is a relationship between two nodes
type Graph ¶ added in v0.14.0
type Graph struct {
// contains filtered or unexported fields
}
Graph is a concurrency safe, mutable, in-memory directed graph
func CustomGraph ¶ added in v1.0.1
CustomGraph creates a new Graph instance with the given Index interface implementations
func NewGraph ¶ added in v0.14.0
func NewGraph() *Graph
NewGraph creates a new in-memory Graph instance
func (*Graph) BFS ¶ added in v0.14.0
BFS executes a depth first search with the rootNode and edge type
func (*Graph) DFS ¶ added in v0.14.0
DFS executes a depth first search with the rootNode and edge type
func (*Graph) RangeEdges ¶ added in v0.14.0
RangeEdges ranges over edges until the given function returns false
func (*Graph) RangeEdgesFrom ¶ added in v0.14.0
func (*Graph) RangeEdgesTo ¶ added in v0.14.0
func (*Graph) RangeNodes ¶ added in v0.14.0
RangeNodes ranges over nodes of the given type until the given function returns false
func (*Graph) ReverseBFS ¶ added in v0.14.0
ReverseBFS executes a reverse depth first search with the rootNode and edge type
func (*Graph) ReverseDFS ¶ added in v0.14.0
ReverseDFS executes a reverse depth first search with the rootNode and edge type
func (*Graph) ReverseTopologicalSort ¶ added in v0.14.0
func (*Graph) SetNode ¶ added in v0.14.0
func (g *Graph) SetNode(key Path, attr Attributes) Node
SetNode sets a node in the graph
Example ¶
package main import ( "fmt" "github.com/autom8ter/dagger" ) func main() { var g = dagger.NewGraph() g.SetNode(dagger.Path{ XID: "virtual_machine_1", XType: "infra", }, map[string]interface{}{}) g.SetNode(dagger.Path{ XID: "virtual_machine_2", XType: "infra", }, map[string]interface{}{}) g.SetNode(dagger.Path{ XID: "kubernetes", XType: "infra", }, map[string]interface{}{}) g.SetNode(dagger.Path{ XID: "redis", XType: "infra", }, map[string]interface{}{ "port": "6379", }) g.SetNode(dagger.Path{ XID: "mongo", XType: "infra", }, map[string]interface{}{ "port": "5568", }) g.SetNode(dagger.Path{ XID: "http", XType: "infra", }, map[string]interface{}{ "port": "8080", }) g.RangeNodes("*", func(n dagger.Node) bool { fmt.Printf("found node in graph: %s.%s\n", n.XType, n.XID) return true }) }
Output:
type Node ¶
type Node struct { Path `json:"path"` Attributes Attributes `json:"attributes"` }
Node is a single entity in the graph.