graphout

package
v0.0.0-...-f10218a Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package graphout implements functions to write graphs to common graph formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DotString

func DotString(s string) string

DotString returns s as a quoted dot string.

Users of the Dot type don't need to call this, since it will automatically quote strings. However, this is useful for building custom dot output.

Types

type Dot

type Dot struct {
	// Name is the name given to the graph. Usually this can be
	// left blank.
	Name string

	// Label returns the string to use as a label for the given
	// node. If nil, nodes are labeled with their node numbers.
	Label func(node int) string

	// NodeAttrs, if non-nil, returns a set of attributes for a
	// node. If this includes a "label" attribute, it overrides
	// the label returned by Label.
	NodeAttrs func(node int) []DotAttr

	// EdgeAttrs, if non-nil, returns a set of attributes for an
	// edge.
	EdgeAttrs func(node, edge int) []DotAttr
}

Dot contains options for generating a Graphviz Dot graph from a Graph.

func (Dot) Fprint

func (d Dot) Fprint(w io.Writer, g graph.Graph) error

Fprint writes the Dot form of g to w.

func (Dot) Print

func (d Dot) Print(g graph.Graph) error

Print writes the Dot form of g to os.Stdout.

func (Dot) Sprint

func (d Dot) Sprint(g graph.Graph) string

Sprint returns the Dot form of g as a string.

type DotAttr

type DotAttr struct {
	Name string
	// Val is the value of this attribute. It may be a string
	// (which will be escaped), bool, int, uint, float64 or
	// DotLiteral.
	Val interface{}
}

DotAttr is an attribute for a Dot node or edge.

type DotLiteral

type DotLiteral string

DotLiteral is a string literal that should be passed to dot unescaped.

Jump to

Keyboard shortcuts

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