gographviz

package module
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: Apache-2.0, BSD-3-Clause Imports: 7 Imported by: 306

README

Parses the Graphviz DOT language and creates an interface, in golang, with which to easily create new and manipulate existing graphs which can be written back to the DOT format.

This parser has been created using gocc.

Example (Parse and Edit)

graphAst, _ := gographviz.ParseString(`digraph G {}`)
graph := gographviz.NewGraph()
if err := gographviz.Analyse(graphAst, graph); err != nil {
    panic(err)
}
graph.AddNode("G", "a", nil)
graph.AddNode("G", "b", nil)
graph.AddEdge("a", "b", true, nil)
output := graph.String()

Documentation

Installation

go get github.com/awalterschulze/gographviz

Build and Tests

Build Status

Users

  • aptly - Debian repository management tool
  • gorgonia - A Library that helps facilitate machine learning in Go
  • imagemonkey - Let's create our own image dataset
  • depviz - GitHub dependency visualizer (auto-roadmap)
  • kustomize-graph - A tool to visualize Kustomize dependencies
  • inframap - Read your tfstate or HCL to generate a graph specific for each Terraform provider
  • Antrea Traceflow supports using Traceflow for network diagnosis for Antrea, a Kubernetes networking solution intended to be Kubernetes native

Mentions

Using Golang and GraphViz to Visualize Complex Grails Applications

Documentation

Overview

Package gographviz provides parsing for the DOT grammar into an abstract syntax tree representing a graph, analysis of the abstract syntax tree into a more usable structure, and writing back of this structure into the DOT format.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Analyse

func Analyse(graph *ast.Graph, g Interface) error

Analyse analyses an Abstract Syntax Tree representing a parsed graph into a newly created graph structure Interface.

func Parse

func Parse(buf []byte) (*ast.Graph, error)

Parse parses the buffer into a abstract syntax tree representing the graph.

func ParseString

func ParseString(buf string) (*ast.Graph, error)

ParseString parses the buffer into a abstract syntax tree representing the graph.

Types

type Attr

type Attr string

Attr is an attribute key

const (
	// Damping http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:Damping
	Damping Attr = "Damping"
	// K http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:K
	K Attr = "K"
	// URL http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:URL
	URL Attr = "URL"
	// Background http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:_background
	Background Attr = "_background"
	// Area http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:area
	Area Attr = "area"
	// ArrowHead http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:arrowhead
	ArrowHead Attr = "arrowhead"
	// ArrowSize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:arrowsize
	ArrowSize Attr = "arrowsize"
	// ArrowTail http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:arrowtail
	ArrowTail Attr = "arrowtail"
	// BB http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:bb
	BB Attr = "bb"
	// BgColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:bgcolor
	BgColor Attr = "bgcolor"
	// Center http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:center
	Center Attr = "center"
	// Charset http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:charset
	Charset Attr = "charset"
	// ClusterRank http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:clusterrank
	ClusterRank Attr = "clusterrank"
	// Color http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:color
	Color Attr = "color"
	// ColorScheme http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:colorscheme
	ColorScheme Attr = "colorscheme"
	// Comment http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:comment
	Comment Attr = "comment"
	// Compound http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:compound
	Compound Attr = "compound"
	// Concentrate http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:concentrate
	Concentrate Attr = "concentrate"
	// Constraint http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:constraint
	Constraint Attr = "constraint"
	// Decorate http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:decorate
	Decorate Attr = "decorate"
	// DefaultDist http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:defaultdist
	DefaultDist Attr = "defaultdist"
	// Dim http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:dim
	Dim Attr = "dim"
	// Dimen http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:dimen
	Dimen Attr = "dimen"
	// Dir http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:dir
	Dir Attr = "dir"
	// DirEdgeConstraints http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:dir
	DirEdgeConstraints Attr = "diredgeconstraints"
	// Distortion http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:distortion
	Distortion Attr = "distortion"
	// DPI http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:dpi
	DPI Attr = "dpi"
	// EdgeURL http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::edgeURL
	EdgeURL Attr = "edgeURL"
	// EdgeHREF http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::edgehref
	EdgeHREF Attr = "edgehref"
	// EdgeTarget http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::edgetarget
	EdgeTarget Attr = "edgetarget"
	// EdgeTooltip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::edgetooltip
	EdgeTooltip Attr = "edgetooltip"
	// Epsilon http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::epsilon
	Epsilon Attr = "epsilon"
	// ESep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d::epsilon
	ESep Attr = "esep"
	// FillColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fillcolor
	FillColor Attr = "fillcolor"
	// FixedSize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fixedsize
	FixedSize Attr = "fixedsize"
	// FontColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fontcolor
	FontColor Attr = "fontcolor"
	// FontName http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fontname
	FontName Attr = "fontname"
	// FontNames http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fontnames
	FontNames Attr = "fontnames"
	// FontPath http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fontpath
	FontPath Attr = "fontpath"
	// FontSize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:fontsize
	FontSize Attr = "fontsize"
	// ForceLabels http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:forcelabels
	ForceLabels Attr = "forcelabels"
	// GradientAngle http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:gradientangle
	GradientAngle Attr = "gradientangle"
	// Group http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:group
	Group Attr = "group"
	// HeadURL http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headURL
	HeadURL Attr = "headURL"
	// HeadLP http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:head_lp
	HeadLP Attr = "head_lp"
	// HeadClip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headclip
	HeadClip Attr = "headclip"
	// HeadHREF http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headhref
	HeadHREF Attr = "headhref"
	// HeadLabel http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headlabel
	HeadLabel Attr = "headlabel"
	// HeadPort http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headport
	HeadPort Attr = "headport"
	// HeadTarget http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headtarget
	HeadTarget Attr = "headtarget"
	// HeadTooltip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headtooltip
	HeadTooltip Attr = "headtooltip"
	// Height http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:height
	Height Attr = "height"
	// HREF http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:href
	HREF Attr = "href"
	// ID http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:id
	ID Attr = "id"
	// Image http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:image
	Image Attr = "image"
	// ImagePath http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagepath
	ImagePath Attr = "imagepath"
	// ImagePos https://graphviz.org/doc/info/attrs.html#d:imagepos
	ImagePos Attr = "imagepos"
	// ImageScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagescale
	ImageScale Attr = "imagescale"
	// InputScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:inputscale
	InputScale Attr = "inputscale"
	// Label http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:label
	Label Attr = "label"
	// LabelURL http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelURL
	LabelURL Attr = "labelURL"
	// LabelScheme http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:label_scheme
	LabelScheme Attr = "label_scheme"
	// LabelAngle http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelangle
	LabelAngle Attr = "labelangle"
	// LabelDistance http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labeldistance
	LabelDistance Attr = "labeldistance"
	// LabelFloat http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelfloat
	LabelFloat Attr = "labelfloat"
	// LabelFontColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelfontcolor
	LabelFontColor Attr = "labelfontcolor"
	// LabelFontName http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelfontname
	LabelFontName Attr = "labelfontname"
	// LabelFontSize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelfontsize
	LabelFontSize Attr = "labelfontsize"
	// LabelHREF http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelhref
	LabelHREF Attr = "labelhref"
	// LabelJust http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labeljust
	LabelJust Attr = "labeljust"
	// LabelLOC http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labelloc
	LabelLOC Attr = "labelloc"
	// LabelTarget http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labeltarget
	LabelTarget Attr = "labeltarget"
	// LabelTooltip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:labeltooltip
	LabelTooltip Attr = "labeltooltip"
	// Landscape http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:landscape
	Landscape Attr = "landscape"
	// Layer http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layer
	Layer Attr = "layer"
	// LayerListSep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layerlistsep
	LayerListSep Attr = "layerlistsep"
	// Layers http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layers
	Layers Attr = "layers"
	// LayerSelect http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layerselect
	LayerSelect Attr = "layerselect"
	// LayerSep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layersep
	LayerSep Attr = "layersep"
	// Layout http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:layout
	Layout Attr = "layout"
	// Len http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:len
	Len Attr = "len"
	// Levels http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:levels
	Levels Attr = "levels"
	// LevelsGap http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:levelsgap
	LevelsGap Attr = "levelsgap"
	// LHead http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:lhead
	LHead Attr = "lhead"
	// LHeight http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:lheight
	LHeight Attr = "lheight"
	// LP http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:lp
	LP Attr = "lp"
	// LTail http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:ltail
	LTail Attr = "ltail"
	// LWidth http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:lwidth
	LWidth Attr = "lwidth"
	// Margin http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:margin
	Margin Attr = "margin"
	// MaxIter http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:maxiter
	MaxIter Attr = "maxiter"
	// MCLimit http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:mclimit
	MCLimit Attr = "mclimit"
	// MinDist http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:mindist
	MinDist Attr = "mindist"
	// MinLen http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:mindist
	MinLen Attr = "minlen"
	// Mode http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:mode
	Mode Attr = "mode"
	// Model http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:model
	Model Attr = "model"
	// Mosek http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:mosek
	Mosek Attr = "mosek"
	// NewRank http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:newrank
	NewRank Attr = "newrank"
	// NodeSep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:nodesep
	NodeSep Attr = "nodesep"
	// NoJustify http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:nojustify
	NoJustify Attr = "nojustify"
	// Normalize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:normalize
	Normalize Attr = "normalize"
	// NoTranslate http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:notranslate
	NoTranslate Attr = "notranslate"
	// NSLimit http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:nslimit
	NSLimit Attr = "nslimit"
	// NSLimit1 http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:nslimit1
	NSLimit1 Attr = "nslimit1"
	// Ordering http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:nslimit1
	Ordering Attr = "ordering"
	// Orientation http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:orientation
	Orientation Attr = "orientation"
	// OutputOrder http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:outputorder
	OutputOrder Attr = "outputorder"
	// Overlap http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:overlap
	Overlap Attr = "overlap"
	// OverlapScaling http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:overlap_scaling
	OverlapScaling Attr = "overlap_scaling"
	// OverlapShrink http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:overlap_shrink
	OverlapShrink Attr = "overlap_shrink"
	// Pack http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:pack
	Pack Attr = "pack"
	// PackMode http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:packmode
	PackMode Attr = "packmode"
	// Pad http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:pad
	Pad Attr = "pad"
	// Page http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:page
	Page Attr = "page"
	// PageDir http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:pagedir
	PageDir Attr = "pagedir"
	// PenColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:pencolor
	PenColor Attr = "pencolor"
	// PenWidth http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:penwidth
	PenWidth Attr = "penwidth"
	// Peripheries http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:peripheries
	Peripheries Attr = "peripheries"
	// Pin http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:peripheries
	Pin Attr = "pin"
	// Pos http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:pos
	Pos Attr = "pos"
	// QuadTree http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:quadtree
	QuadTree Attr = "quadtree"
	// Quantum http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:quantum
	Quantum Attr = "quantum"
	// Rank http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:rank
	Rank Attr = "rank"
	// RankDir http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:rankdir
	RankDir Attr = "rankdir"
	// RankSep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:ranksep
	RankSep Attr = "ranksep"
	// Ratio http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:ratio
	Ratio Attr = "ratio"
	// Rects http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:rects
	Rects Attr = "rects"
	// Regular http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:regular
	Regular Attr = "regular"
	// ReMinCross http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:remincross
	ReMinCross Attr = "remincross"
	// RepulsiveForce http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:repulsiveforce
	RepulsiveForce Attr = "repulsiveforce"
	// Resolution http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:resolution
	Resolution Attr = "resolution"
	// Root http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:root
	Root Attr = "root"
	// Rotate http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:rotate
	Rotate Attr = "rotate"
	// Rotation http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:rotation
	Rotation Attr = "rotation"
	// SameHead http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:samehead
	SameHead Attr = "samehead"
	// SameTail http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:sametail
	SameTail Attr = "sametail"
	// SamplePoints http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:samplepoints
	SamplePoints Attr = "samplepoints"
	// Scale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:scale
	Scale Attr = "scale"
	// SearchSize http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:searchsize
	SearchSize Attr = "searchsize"
	// Sep http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:sep
	Sep Attr = "sep"
	// Shape http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:shape
	Shape Attr = "shape"
	// ShapeFile http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:shapefile
	ShapeFile Attr = "shapefile"
	// ShowBoxes http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:showboxes
	ShowBoxes Attr = "showboxes"
	// Sides http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:sides
	Sides Attr = "sides"
	// Size http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:size
	Size Attr = "size"
	// Skew http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:skew
	Skew Attr = "skew"
	// Smoothing http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:smoothing
	Smoothing Attr = "smoothing"
	// SortV http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:sortv
	SortV Attr = "sortv"
	// Splines http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:splines
	Splines Attr = "splines"
	// Start http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:start
	Start Attr = "start"
	// Style http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:style
	Style Attr = "style"
	// StyleSheet http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:stylesheet
	StyleSheet Attr = "stylesheet"
	// TailURL http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailURL
	TailURL Attr = "tailURL"
	// TailLP http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tail_lp
	TailLP Attr = "tail_lp"
	// TailClip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailclip
	TailClip Attr = "tailclip"
	// TailHREF http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailhref
	TailHREF Attr = "tailhref"
	// TailLabel http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:taillabel
	TailLabel Attr = "taillabel"
	// TailPort http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailport
	TailPort Attr = "tailport"
	// TailTarget http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailtarget
	TailTarget Attr = "tailtarget"
	// TailTooltip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tailtooltip
	TailTooltip Attr = "tailtooltip"
	// Target http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:target
	Target Attr = "target"
	// Tooltip http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tooltip
	Tooltip Attr = "tooltip"
	// TrueColor http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:tooltip
	TrueColor Attr = "truecolor"
	// Vertices http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:vertices
	Vertices Attr = "vertices"
	// ViewPort http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:viewport
	ViewPort Attr = "viewport"
	// VoroMargin http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:voro_margin
	VoroMargin Attr = "voro_margin"
	// Weight http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:weight
	Weight Attr = "weight"
	// Width http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:width
	Width Attr = "width"
	// XDotVersion http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:xdotversion
	XDotVersion Attr = "xdotversion"
	// XLabel http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:xlabel
	XLabel Attr = "xlabel"
	// XLP http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:xlp
	XLP Attr = "xlp"
	// Z http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:z
	Z Attr = "z"

	// MinCross is not in the documentation, but found in the Ped_Lion_Share (lion_share.gv.txt) example
	MinCross Attr = "mincross"
	// SSize is not in the documentation, but found in the siblings.gv.txt example
	SSize Attr = "ssize"
	// Outline is not in the documentation, but found in the siblings.gv.txt example
	Outline Attr = "outline"
	// F is not in the documentation, but found in the transparency.gv.txt example
	F Attr = "f"
)

func NewAttr

func NewAttr(key string) (Attr, error)

NewAttr creates a new attribute key by checking whether it is a valid key

type Attrs

type Attrs map[Attr]string

Attrs represents attributes for an Edge, Node or Graph.

func NewAttrs

func NewAttrs(m map[string]string) (Attrs, error)

NewAttrs creates an empty Attributes type.

func (Attrs) Add

func (attrs Attrs) Add(field string, value string) error

Add adds an attribute name and value.

func (Attrs) Ammend

func (attrs Attrs) Ammend(more Attrs)

Ammend only adds the missing attributes to attrs Attrs type.

func (Attrs) Copy

func (attrs Attrs) Copy() Attrs

Copy returns a copy of the attributes map

func (Attrs) Extend

func (attrs Attrs) Extend(more Attrs)

Extend adds the attributes into attrs Attrs type overwriting duplicates.

type Edge

type Edge struct {
	Src     string
	SrcPort string
	Dst     string
	DstPort string
	Dir     bool
	Attrs   Attrs
}

Edge represents an Edge.

type Edges

type Edges struct {
	SrcToDsts map[string]map[string][]*Edge
	DstToSrcs map[string]map[string][]*Edge
	Edges     []*Edge
}

Edges represents a set of Edges.

func NewEdges

func NewEdges() *Edges

NewEdges creates a blank set of Edges.

func (*Edges) Add

func (edges *Edges) Add(edge *Edge)

Add adds an Edge to the set of Edges.

func (Edges) Sorted

func (edges Edges) Sorted() []*Edge

Sorted returns a sorted list of Edges.

type Escape

type Escape struct {
	*Graph
}

Escape is just a Graph that escapes some strings when required.

func NewEscape

func NewEscape() *Escape

NewEscape returns a graph which will try to escape some strings when required

func (*Escape) AddAttr

func (escape *Escape) AddAttr(parentGraph string, field, value string) error

AddAttr adds an attribute and escapes the parentGraph, field and value, if needed.

func (*Escape) AddEdge

func (escape *Escape) AddEdge(src, dst string, directed bool, attrs map[string]string) error

AddEdge adds an edge and escapes the src, dst and attrs, if needed.

func (*Escape) AddNode

func (escape *Escape) AddNode(parentGraph string, name string, attrs map[string]string) error

AddNode adds a node and escapes the parentGraph, name and attrs, if needed.

func (*Escape) AddPortEdge

func (escape *Escape) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) error

AddPortEdge adds an edge with ports and escapes the src, dst and attrs, if needed.

func (*Escape) AddSubGraph

func (escape *Escape) AddSubGraph(parentGraph string, name string, attrs map[string]string) error

AddSubGraph adds a subgraph and escapes the parentGraph, name and attrs, if needed.

func (*Escape) IsNode

func (escape *Escape) IsNode(name string) bool

IsNode returns whether the, escaped if needed, name is a node in the graph.

func (*Escape) IsSubGraph

func (escape *Escape) IsSubGraph(name string) bool

IsSubGraph returns whether the, escaped if needed, name is a subgraph in the grahp.

func (*Escape) SetName

func (escape *Escape) SetName(name string) error

SetName sets the graph name and escapes it, if needed.

type Graph

type Graph struct {
	Attrs     Attrs
	Name      string
	Directed  bool
	Strict    bool
	Nodes     *Nodes
	Edges     *Edges
	SubGraphs *SubGraphs
	Relations *Relations
}

Graph is the analysed representation of the Graph parsed from the DOT format.

func NewAnalysedGraph

func NewAnalysedGraph(graph *ast.Graph) (*Graph, error)

NewAnalysedGraph creates a Graph structure by analysing an Abstract Syntax Tree representing a parsed graph.

func NewGraph

func NewGraph() *Graph

NewGraph creates a new empty graph, ready to be populated.

Example
g := NewGraph()
if err := g.SetName("G"); err != nil {
	panic(err)
}
if err := g.SetDir(true); err != nil {
	panic(err)
}
if err := g.AddNode("G", "Hello", nil); err != nil {
	panic(err)
}
if err := g.AddNode("G", "World", nil); err != nil {
	panic(err)
}
if err := g.AddEdge("Hello", "World", true, nil); err != nil {
	panic(err)
}
s := g.String()
fmt.Println(s)
Output:

digraph G {
	Hello->World;
	Hello;
	World;

}

func Read

func Read(buf []byte) (*Graph, error)

Read parses and creates a new Graph from the data.

Example
g, err := Read([]byte(`digraph G {Hello->World}`))
if err != nil {
	panic(err)
}
s := g.String()
fmt.Println(s)
Output:

digraph G {
	Hello->World;
	Hello;
	World;

}

func (*Graph) AddAttr

func (g *Graph) AddAttr(parentGraph string, field string, value string) error

AddAttr adds an attribute to a graph/subgraph.

func (*Graph) AddEdge

func (g *Graph) AddEdge(src, dst string, directed bool, attrs map[string]string) error

AddEdge adds an edge to the graph from node src to node dst. This does not imply the adding of missing nodes. If directed is set to true then SetDir(true) must also be called or there will be a syntax error in the output.

func (*Graph) AddNode

func (g *Graph) AddNode(parentGraph string, name string, attrs map[string]string) error

AddNode adds a node to a graph/subgraph. If not subgraph exists use the name of the main graph. This does not imply the adding of a missing subgraph.

func (*Graph) AddPortEdge

func (g *Graph) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) error

AddPortEdge adds an edge to the graph from node src to node dst. srcPort and dstPort are the port the node ports, leave as empty strings if it is not required. This does not imply the adding of missing nodes.

func (*Graph) AddSubGraph

func (g *Graph) AddSubGraph(parentGraph string, name string, attrs map[string]string) error

AddSubGraph adds a subgraph to a graph/subgraph.

func (*Graph) IsNode

func (g *Graph) IsNode(name string) bool

IsNode returns whether a given node name exists as a node in the graph.

func (*Graph) IsSubGraph

func (g *Graph) IsSubGraph(name string) bool

IsSubGraph returns whether a given subgraph name exists as a subgraph in the graph.

func (*Graph) RemoveNode

func (g *Graph) RemoveNode(parentGraph string, name string) error

RemoveNode removes a node from the graph

func (*Graph) RemoveSubGraph

func (g *Graph) RemoveSubGraph(parentGraph string, name string) error

RemoveSubGraph removes the subgraph including nodes

func (*Graph) SetDir

func (g *Graph) SetDir(dir bool) error

SetDir sets whether the graph is directed (true) or undirected (false).

func (*Graph) SetName

func (g *Graph) SetName(name string) error

SetName sets the graph name.

func (*Graph) SetStrict

func (g *Graph) SetStrict(strict bool) error

SetStrict sets whether a graph is strict. If the graph is strict then multiple edges are not allowed between the same pairs of nodes, see dot man page.

func (*Graph) String

func (g *Graph) String() string

String returns a DOT string representing the Graph.

func (*Graph) WriteAst

func (g *Graph) WriteAst() (*ast.Graph, error)

WriteAst creates an Abstract Syntrax Tree from the Graph.

type Interface

type Interface interface {
	SetStrict(strict bool) error
	SetDir(directed bool) error
	SetName(name string) error
	AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) error
	AddEdge(src, dst string, directed bool, attrs map[string]string) error
	AddNode(parentGraph string, name string, attrs map[string]string) error
	AddAttr(parentGraph string, field, value string) error
	AddSubGraph(parentGraph string, name string, attrs map[string]string) error
	String() string
}

Interface allows you to parse the graph into your own structure.

type Node

type Node struct {
	Name  string
	Attrs Attrs
}

Node represents a Node.

type Nodes

type Nodes struct {
	Lookup map[string]*Node
	Nodes  []*Node
}

Nodes represents a set of Nodes.

func NewNodes

func NewNodes() *Nodes

NewNodes creates a new set of Nodes.

func (*Nodes) Add

func (nodes *Nodes) Add(node *Node)

Add adds a Node to the set of Nodes, extending the attributes of an already existing node.

func (*Nodes) Remove

func (nodes *Nodes) Remove(name string) error

Remove removes a node

func (Nodes) Sorted

func (nodes Nodes) Sorted() []*Node

Sorted returns a sorted list of nodes.

type Relations

type Relations struct {
	ParentToChildren map[string]map[string]bool
	ChildToParents   map[string]map[string]bool
}

Relations represents the relations between graphs and nodes. Each node belongs the main graph or a subgraph.

func NewRelations

func NewRelations() *Relations

NewRelations creates an empty set of relations.

func (*Relations) Add

func (relations *Relations) Add(parent string, child string)

Add adds a node to a parent graph.

func (*Relations) Remove

func (relations *Relations) Remove(parent string, child string)

Remove removes relation

func (*Relations) SortedChildren

func (relations *Relations) SortedChildren(parent string) []string

SortedChildren returns a list of sorted children of the given parent graph.

type SubGraph

type SubGraph struct {
	Attrs Attrs
	Name  string
}

SubGraph represents a Subgraph.

func NewSubGraph

func NewSubGraph(name string) *SubGraph

NewSubGraph creates a new Subgraph.

type SubGraphs

type SubGraphs struct {
	SubGraphs map[string]*SubGraph
}

SubGraphs represents a set of SubGraphs.

func NewSubGraphs

func NewSubGraphs() *SubGraphs

NewSubGraphs creates a new blank set of SubGraphs.

func (*SubGraphs) Add

func (subgraphs *SubGraphs) Add(name string)

Add adds and creates a new Subgraph to the set of SubGraphs.

func (*SubGraphs) Remove

func (subgraphs *SubGraphs) Remove(name string)

Remove removes a subgraph

func (*SubGraphs) Sorted

func (subgraphs *SubGraphs) Sorted() []*SubGraph

Sorted returns a sorted list of SubGraphs.

Directories

Path Synopsis
Abstract Syntax Tree representing the DOT grammar
Abstract Syntax Tree representing the DOT grammar
internal
parser
A parser for the DOT grammar.
A parser for the DOT grammar.

Jump to

Keyboard shortcuts

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