graph

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2020 Fugue, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	F, T Node
}

Edge is a simple graph edge.

func (Edge) From

func (e Edge) From() Node

From returns the from-node of the edge.

func (Edge) To

func (e Edge) To() Node

To returns the to-node of the edge.

type Graph

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

Graph used to sort Components based on dependencies

func NewGraph

func NewGraph() *Graph

NewGraph returns an empty Graph

func (*Graph) Add

func (g *Graph) Add(n ...Node) *Graph

Add a Node to the Graph

func (*Graph) Connect

func (g *Graph) Connect(from, to Node) *Graph

Connect declares a directional link two nodes in the Graph

func (*Graph) Count

func (g *Graph) Count() int

Count returns the number of Nodes in the Graph

func (*Graph) Filter

func (g *Graph) Filter(filter NodeFilter) (result []Node)

Filter nodes in the Graph

func (*Graph) From

func (g *Graph) From(n Node) []Node

From returns all nodes in the graph that can be reached directly from the specified Node

func (*Graph) GetNode

func (g *Graph) GetNode(nodeID string) (Node, bool)

GetNode returns the Node with the specified ID and a boolean indicating whether it was found

func (*Graph) Remove

func (g *Graph) Remove(n ...Node) *Graph

Remove a Node from the Graph

func (*Graph) Sort

func (g *Graph) Sort() ([]Node, error)

Sort returns a topological sort of the Graph

func (*Graph) To

func (g *Graph) To(n Node) []Node

To returns all nodes in the graph that can reach the specified node

func (*Graph) Visit

func (g *Graph) Visit(callback VisitCallback)

Visit all nodes in the Graph and call the provided callback for each

type Node

type Node interface {
	NodeID() string
}

Node defines NodeID() which is used to identify a Node in a Graph

type NodeFilter

type NodeFilter func(n Node) bool

NodeFilter is a filter function for Graph nodes

type VisitCallback

type VisitCallback func(n Node) bool

VisitCallback is a function signature for visiting nodes in the graph

Jump to

Keyboard shortcuts

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