graph

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 5 Imported by: 1

README

Go Reference Tests Coverage Status Go Report Card Quality Gate Status

Graph

This package provides a tool to detect circular dependencies and find all dependant nodes in directed graphs.

g := graph.New()
g.AddDep("company", "tech-team")
g.AddDep("tech-team", "cto")
g.AddDep("cto", "company")
g.AddDep("cto", "ceo")
g.AddDep("ceo", "company")

fmt.Println(g.CircularDeps())

// Output:
// [[company tech-team cto company] [company tech-team cto ceo company]]

See examples.

Documentation

Overview

Package graph provides a tool to detect circular dependencies and find all dependant nodes in directed graphs.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *graph
Example (CircularDeps)
package main

import (
	"fmt"

	"github.com/gontainer/graph"
)

func main() {
	g := graph.New()
	g.AddDep("company", "tech-team")
	g.AddDep("tech-team", "cto")
	g.AddDep("cto", "company")
	g.AddDep("cto", "ceo")
	g.AddDep("ceo", "company")

	fmt.Println(g.CircularDeps())

}
Output:

[[company tech-team cto company] [company tech-team cto ceo company]]
Example (Deps)
package main

import (
	"fmt"

	"github.com/gontainer/graph"
)

func main() {
	g := graph.New()
	g.AddDep("company", "tech-team")
	g.AddDep("tech-team", "cto")

	fmt.Println(g.Deps("company"))

}
Output:

[cto tech-team]

Types

This section is empty.

Jump to

Keyboard shortcuts

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