graph

package
v0.0.0-...-472ff39 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSubgraphHasNode

func GetSubgraphHasNode(graph Graph, start string, target string) bool

A faster alternative to GetSubgraph(graph, start).HasNode(target)

func GetSubgraphNodeCount

func GetSubgraphNodeCount(graph Graph, start string) int

A faster alternative to GetSubgraph(graph, start).GetNodeCount()

func NewNode

func NewNode(id string) *node

func ToString

func ToString(graph Graph) string

Return graphviz string representation, we can output this to file and preview in eg. xdot or any other tool for graphviz

Types

type Attributes

type Attributes map[string]string

type ByNodePriority

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

func (ByNodePriority) Len

func (a ByNodePriority) Len() int

func (ByNodePriority) Less

func (a ByNodePriority) Less(i, j int) bool

func (ByNodePriority) Swap

func (a ByNodePriority) Swap(i, j int)

type Graph

type Graph interface {
	GetNodeCount() int

	GetName() string

	HasNode(id string) bool
	HasEdge(source, target string) bool

	GetNodes() []string

	SetNodeProperty(id, key, value string)
	SetNodeAttributes(id string, attributes Attributes)
	SetNodeBackgroundColor(id, color string)

	GetNodeAttributes(id string) (Attributes, error)

	Merge(mergeGraph Graph)

	GetNodePriority(id string) (int, error)
	SetNodePriority(id string, priority int) error

	// return false if the node already present in the graph
	AddNode(id string) bool

	// return true if successfully removed from graph
	DeleteNode(id string) bool
	CutSubgraph(root string)

	// Removes node in this way that will keep connected parents to children of the node
	// eg. A -> B -> C, if we remove B then we will get A -> C
	DeleteProxyNode(id string)

	// Remove an edge, and replicate the outgoing connections of the target node onto the source node.
	// The edge being removed is a proxy for these connections. This is similar to DeleteProxyNode, but only deletes one of the incoming edges.
	DeleteProxyEdge(source, target string)
	// DeleteProxyEdge for edges that have a particular color
	DeleteProxyEdges(color string)
	// Like DeleteProxyEdge but additionally set edge color to replicate ones
	DeleteProxyEdgeSetColor(source, proxy, color string)

	GetEdgeAttributes(source, target string) (Attributes, error)
	SetEdgeAttributes(source, target string, attributes Attributes) bool

	AddEdge(source, target string) bool
	AddEdgeToExistingNodes(source, target string) (bool, error)
	SetEdgeColor(source, target string, color string)
	SetEdgeWeight(source, target string, weight int)
	SetEdgeConstraint(source, target string, constraint bool)
	SetEdgeProperty(source, target, key, value string)

	DeleteEdge(source, target string) error

	// GetSources returns the list of parent Nodes.
	// (Nodes that come towards the argument vertex.)
	GetSources(id string) ([]string, error)

	// GetTargets returns the list of child Nodes.
	// (Nodes that go out of the argument vertex.)
	GetTargets(id string) ([]string, error)

	IsReachable(source, target string) bool
	// contains filtered or unexported methods
}

func GetSubgraph

func GetSubgraph(graph Graph, start string) Graph

A subgraph of a graph G is another graph formed from a subset of the vertices and edges of G. The vertex subset must include all endpoints of the edge subset. subgraph: https://en.wikipedia.org/wiki/Glossary_of_graph_theory_terms#subgraph

func GetSubgraphs

func GetSubgraphs(graph Graph) []Graph

Retrive all possible SubGraphs. Check GetSubGraph to understand what is sub graph

func NewGraph

func NewGraph(name string) Graph

Jump to

Keyboard shortcuts

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