graph

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

Graph plotting

The graph command presents a structured representation of the dependency graph that is constructed in the dependencies package.

Possible output formats are json, yaml, and flat.

The following dependency graph

A ← + ← C ← E
    ↑   ↑
    + ← D

would be encoded as

A: {}
C:
  0: [A]
D:
  0: [A, C]
E:
  0: [C]
  1: [A]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentDependencies

type ComponentDependencies map[string]WeightedDeps

ComponentDependencies holds a complete representation of all dependencies from upstream to downstream dependencies for all components. Dependencies are weighted by their distance to the reference component (the top-level key)

weight 0: a direct dependency
weight 1: indirect dependency (1 level in between)

E.g.:

A ← + ← C ← E
    ↑   ↑
    + ← D

encoded as

map[
  A: map[],
  C: map[0:map[A:true]],
  D: map[0:map[A:true, C:true]],
  E: map[0:map[C:true], 1:map[A:true]]
]

func GenerateUpToDown

func GenerateUpToDown(components DownToUp) ComponentDependencies

GenerateUpToDown constructs a dependency graph that flows from upstream to downstream components (where component A is downstream of C if it depends on C). The graph is constructed from a map of all direct dependencies (given in form downstream to upstream). E.g. the input

A → + → C → E
    ↓   ↓
    + → D

will result in the upstream to downstream graph

A ← + ← C ← E
    ↑   ↑
    + ← D

encoded as

map[
  A: map[],
  C: map[0:map[A:true]],
  D: map[0:map[A:true, C:true]],
  E: map[0:map[C:true], 1:map[A:true]]
]

func (ComponentDependencies) Keys

func (cd ComponentDependencies) Keys() []string

func (ComponentDependencies) MaxDepth

func (ComponentDependencies) Print

func (cd ComponentDependencies) Print(w io.Writer, format OutputFormat) error

For each components Print returns the upstream dependencies weighted by the number of links separating them from the component in question. In yaml format the output will have the form

{componentName: {weight: [dependency-1, dependency-2, ...], ...}, ...}

In json format the output will have the form

{componentName: [[dependency-1, dependency-2, ...], ...], ...}

where the outer array is ordered by increasing weights.

type DownToUp

type DownToUp map[string]map[string]bool

DownToUp is a map from downstream components to all their direct upstream dependencies. E.g. the graph

A -+ → C
   |
   + → D

would be encoded as map[A] = {C,D}

type OutputFormat

type OutputFormat string
const (
	JSON  OutputFormat = "json"
	YAML  OutputFormat = "yaml"
	FLAT  OutputFormat = "flat"
	UNSET OutputFormat = "unset"
)

func CastOutputFormat

func CastOutputFormat(s string) (OutputFormat, bool)

type WeightedDeps

type WeightedDeps map[int]map[string]bool

func (WeightedDeps) Keys

func (wd WeightedDeps) Keys() []int

func (WeightedDeps) ToArray

func (wd WeightedDeps) ToArray() [][]string

Jump to

Keyboard shortcuts

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