dot

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: ISC Imports: 4 Imported by: 0

README

DOT

This package is for creating Graphviz graphs and generating the DOT language code.

Documentation

Overview

Package dot provides a basic implementation of the DOT language for visualizing graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrowType

type ArrowType string
const (
	ArrowTypeNone     ArrowType = "none"
	ArrowTypeNormal   ArrowType = "normal"
	ArrowTypeInv      ArrowType = "inv"
	ArrowTypeDot      ArrowType = "dot"
	ArrowTypeInvDot   ArrowType = "invdot"
	ArrowTypeODot     ArrowType = "odot"
	ArrowTypeInvODot  ArrowType = "invodot"
	ArrowTypeEmpty    ArrowType = "empty"
	ArrowTypeInvEmpty ArrowType = "invempty"
	ArrowTypeBox      ArrowType = "box"
	ArrowTypeOBox     ArrowType = "obox"
	ArrowTypeDiamond  ArrowType = "diamond"
	ArrowTypeODiamond ArrowType = "odiamond"
	ArrowTypeEDiamond ArrowType = "ediamond"
	ArrowTypeOpen     ArrowType = "open"
	ArrowTypeHalfOpen ArrowType = "halfopen"
	ArrowTypeVee      ArrowType = "vee"
	ArrowTypeTee      ArrowType = "tee"
	ArrowTypeCrow     ArrowType = "crow"
)

type Color

type Color string
const (
	ColorAliceBlue            Color = "aliceblue"
	ColorAntiqueWhite         Color = "antiquewhite"
	ColorAqua                 Color = "aqua"
	ColorAquaMarine           Color = "aquamarine"
	ColorAzure                Color = "azure"
	ColorBeige                Color = "beige"
	ColorBisque               Color = "bisque"
	ColorBlack                Color = "black"
	ColorBlanchedAlmond       Color = "blanchedalmond"
	ColorBlue                 Color = "blue"
	ColorBlueViolet           Color = "blueviolet"
	ColorBrown                Color = "brown"
	ColorBurlyWood            Color = "burlywood"
	ColorCadetBlue            Color = "cadetblue"
	ColorChartreuse           Color = "chartreuse"
	ColorChocolate            Color = "chocolate"
	ColorCoral                Color = "coral"
	ColorCornFlowerBlue       Color = "cornflowerblue"
	ColorCornSilk             Color = "cornsilk"
	ColorCrimson              Color = "crimson"
	ColorCyan                 Color = "cyan"
	ColorDarkblue             Color = "darkblue"
	ColorDarkCyan             Color = "darkcyan"
	ColorDarkGoldenrod        Color = "darkgoldenrod"
	ColorDarkGray             Color = "darkgray"
	ColorDarkGreen            Color = "darkgreen"
	ColorDarkGrey             Color = "darkgrey"
	ColorDarkKhaki            Color = "darkkhaki"
	ColorDarkMagenta          Color = "darkmagenta"
	ColorDarkOliveGreen       Color = "darkolivegreen"
	ColorDarkOrange           Color = "darkorange"
	ColorDarkOrchid           Color = "darkorchid"
	ColorDarkRed              Color = "darkred"
	ColorDarkSalmon           Color = "darksalmon"
	ColorDarkSeaGreen         Color = "darkseagreen"
	ColorDarkSlateBlue        Color = "darkslateblue"
	ColorDarkSlateGray        Color = "darkslategray"
	ColorDarkSlateGrey        Color = "darkslategrey"
	ColorDarkTurquoise        Color = "darkturquoise"
	ColorDarkViolet           Color = "darkviolet"
	ColorDeepPink             Color = "deeppink"
	ColorDeepSkyBlue          Color = "deepskyblue"
	ColorDimGray              Color = "dimgray"
	ColorDimGrey              Color = "dimgrey"
	ColorDoderBlue            Color = "dodgerblue"
	ColorFireBrick            Color = "firebrick"
	ColorFloralWhite          Color = "floralwhite"
	ColorForestGreen          Color = "forestgreen"
	ColorFuchsia              Color = "fuchsia"
	ColorGainsboro            Color = "gainsboro"
	ColorGhostWhite           Color = "ghostwhite"
	ColorGold                 Color = "gold"
	ColorGoldenrod            Color = "goldenrod"
	ColorGray                 Color = "gray"
	ColorGreen                Color = "green"
	ColorGreenYellow          Color = "greenyellow"
	ColorGrey                 Color = "grey"
	ColorHoneydew             Color = "honeydew"
	ColorHotPink              Color = "hotpink"
	ColorIndianRed            Color = "indianred"
	ColorIndigo               Color = "indigo"
	ColorIvory                Color = "ivory"
	ColorKhaki                Color = "khaki"
	ColorLavender             Color = "lavender"
	ColorLavenderBlush        Color = "lavenderblush"
	ColorLawnGreen            Color = "lawngreen"
	ColorLemonChiffon         Color = "lemonchiffon"
	ColorLightBlue            Color = "lightblue"
	ColorLightCoral           Color = "lightcoral"
	ColorLightCyan            Color = "lightcyan"
	ColorLightGoldenrodYellow Color = "lightgoldenrodyellow"
	ColorLightGray            Color = "lightgray"
	ColorLightGreen           Color = "lightgreen"
	ColorLightGrey            Color = "lightgrey"
	ColorLightPink            Color = "lightpink"
	ColorLightSalmon          Color = "lightsalmon"
	ColorLightSeaGreen        Color = "lightseagreen"
	ColorLightSkyBlue         Color = "lightskyblue"
	ColorLightSlateGray       Color = "lightslategray"
	ColorLightSlateGrey       Color = "lightslategrey"
	ColorLightSteelBlue       Color = "lightsteelblue"
	ColorLightYellow          Color = "lightyellow"
	ColorLime                 Color = "lime"
	ColorLimeGreen            Color = "limegreen"
	ColorLinen                Color = "linen"
	ColorMagenta              Color = "magenta"
	ColorMaroon               Color = "maroon"
	ColorMediumAquaMarine     Color = "mediumaquamarine"
	ColorMediumBlue           Color = "mediumblue"
	ColorMediumOrchid         Color = "mediumorchid"
	ColorMediumPurple         Color = "mediumpurple"
	ColorMediumSeaGreen       Color = "mediumseagreen"
	ColorMediumSlateBlue      Color = "mediumslateblue"
	ColorMediumSpringGreen    Color = "mediumspringgreen"
	ColorMediumTurquoise      Color = "mediumturquoise"
	ColorMediumVioletRed      Color = "mediumvioletred"
	ColorMidnightBlue         Color = "midnightblue"
	ColorMintCream            Color = "mintcream"
	ColorMistyRose            Color = "mistyrose"
	ColorMoccasin             Color = "moccasin"
	ColorNavajoWhite          Color = "navajowhite"
	ColorNavy                 Color = "navy"
	ColorOldLace              Color = "oldlace"
	ColorOlive                Color = "olive"
	ColorOliveDrab            Color = "olivedrab"
	ColorOrange               Color = "orange"
	ColorOrangeRed            Color = "orangered"
	ColorOrchid               Color = "orchid"
	ColorPaleGoldenRod        Color = "palegoldenrod"
	ColorPaleGreen            Color = "palegreen"
	ColorPaleTurquoise        Color = "paleturquoise"
	ColorPaleVioletRed        Color = "palevioletred"
	ColorPapayaWhip           Color = "papayawhip"
	ColorPeachPuff            Color = "peachpuff"
	ColorPeru                 Color = "peru"
	ColorPink                 Color = "pink"
	ColorPlum                 Color = "plum"
	ColorPowderBlue           Color = "powderblue"
	ColorPurple               Color = "purple"
	ColorRed                  Color = "red"
	ColorRosyBrown            Color = "rosybrown"
	ColorRoyalBlue            Color = "royalblue"
	ColorSaddleBrown          Color = "saddlebrown"
	ColorSalmon               Color = "salmon"
	ColorSandyBrown           Color = "sandybrown"
	ColorSeaGreen             Color = "seagreen"
	ColorSeashell             Color = "seashell"
	ColorSienna               Color = "sienna"
	ColorSilver               Color = "silver"
	ColorSkyBlue              Color = "skyblue"
	ColorSlateBlue            Color = "slateblue"
	ColorSlateGray            Color = "slategray"
	ColorSlateGrey            Color = "slategrey"
	ColorSnow                 Color = "snow"
	ColorSpringGreen          Color = "springgreen"
	ColorSteelBlue            Color = "steelblue"
	ColorTan                  Color = "tan"
	ColorTeal                 Color = "teal"
	ColorThistle              Color = "thistle"
	ColorTomato               Color = "tomato"
	ColorTurquoise            Color = "turquoise"
	ColorViolet               Color = "violet"
	ColorWheat                Color = "wheat"
	ColorWhite                Color = "white"
	ColorWhiteSmoke           Color = "whitesmoke"
	ColorYellow               Color = "yellow"
	ColorYellowGreen          Color = "yellowgreen"
)

type Edge

type Edge struct {
	From      string
	To        string
	EdgeType  EdgeType
	EdgeDir   EdgeDir
	Label     string
	Color     Color
	Style     Style
	ArrowHead ArrowType
	ArrowTail ArrowType
}

Edge represents an edge.

func NewEdge

func NewEdge(from, to string, edgeType EdgeType, edgeDir EdgeDir, label string, color Color, style Style, arrowHead, arrowTail ArrowType) Edge

NewEdge creates a new edge.

func (*Edge) DOT

func (e *Edge) DOT() string

DOT generates a DOT representation of the Edge object.

type EdgeDir

type EdgeDir string
const (
	EdgeDirNone    EdgeDir = "none"
	EdgeDirForward EdgeDir = "forward"
	EdgeDirBack    EdgeDir = "back"
	EdgeDirBoth    EdgeDir = "both"
)

type EdgeType

type EdgeType string
const (
	EdgeTypeDirected   EdgeType = "->"
	EdgeTypeUndirected EdgeType = "--"
)

type Field

type Field interface {
	DOT() string
}

Field represents a field.

func NewComplexField

func NewComplexField(record Record) Field

NewComplexField creates a new complex field.

func NewSimpleField

func NewSimpleField(name, label string) Field

NewSimpleField creates a new simple field.

type Graph

type Graph struct {
	Strict      bool
	Digraph     bool
	Concentrate bool
	Name        string
	RankDir     RankDir
	NodeColor   Color
	NodeStyle   Style
	NodeShape   Shape
	Nodes       []Node
	Edges       []Edge
	Subgraphs   []Subgraph
}

Graph represents a graph.

func NewGraph

func NewGraph(strict, digraph, concentrate bool, name string, rankDir RankDir, nodeColor Color, nodeStyle Style, nodeShape Shape) Graph

NewGraph creates a new graph.

func (*Graph) AddEdge

func (g *Graph) AddEdge(edges ...Edge)

AddEdge adds a new edge to this graph.

func (*Graph) AddNode

func (g *Graph) AddNode(nodes ...Node)

AddNode adds a new node to this graph.

func (*Graph) AddSubgraph

func (g *Graph) AddSubgraph(subgraphs ...Subgraph)

AddSubgraph adds a new subgraph to this graph.

func (*Graph) DOT

func (g *Graph) DOT() string

DOT generates a DOT representation of the Graph object.

type Node

type Node struct {
	Name      string
	Group     string
	Label     string
	Color     Color
	Style     Style
	Shape     Shape
	FontColor Color
	FontName  string
}

Node represents a graph node.

func NewNode

func NewNode(name, group, label string, color Color, style Style, shape Shape, fontcolor Color, fontname string) Node

NewNode creates a new node.

func (*Node) DOT

func (n *Node) DOT() string

DOT generates a DOT representation of the Node object.

type Rank

type Rank string
const (
	RankSame   Rank = "same"
	RankMin    Rank = "min"
	RankMax    Rank = "max"
	RankSink   Rank = "sink"
	RankSource Rank = "source"
)

type RankDir

type RankDir string
const (
	RankDirLR RankDir = "LR"
	RankDirRL RankDir = "RL"
	RankDirTB RankDir = "TB"
	RankDirBT RankDir = "BT"
)

type Record

type Record struct {
	Fields []Field
}

Record represents a record.

func NewRecord

func NewRecord(fields ...Field) Record

NewRecord creates a new record.

func (*Record) AddField

func (r *Record) AddField(f Field)

AddField adds a new field to the record.

func (*Record) Label

func (r *Record) Label() string

Label returns the label for a node with record or Mrecord shape.

type Shape

type Shape string
const (
	ShapeNone          Shape = "none"
	ShapePlaintext     Shape = "plaintext"
	ShapePlain         Shape = "plain"
	ShapeUnderline     Shape = "underline"
	ShapeBox           Shape = "box"
	ShapePolygon       Shape = "polygon"
	ShapeEllipse       Shape = "ellipse"
	ShapeOval          Shape = "oval"
	ShapeCircle        Shape = "circle"
	ShapePoint         Shape = "point"
	ShapeEgg           Shape = "egg"
	ShapeTriangle      Shape = "triangle"
	ShapeDiamond       Shape = "diamond"
	ShapeTrapezium     Shape = "trapezium"
	ShapeParallelogram Shape = "parallelogram"
	ShapeHouse         Shape = "house"
	ShapePentagon      Shape = "pentagon"
	ShapeHexagon       Shape = "hexagon"
	ShapeSeptagon      Shape = "septagon"
	ShapeOctagon       Shape = "octagon"
	ShapeDoubleCircle  Shape = "doublecircle"
	ShapeDoubleOctagon Shape = "doubleoctagon"
	ShapeTripleOctagon Shape = "tripleoctagon"
	ShapeInvTriangle   Shape = "invtriangle"
	ShapeInvTrapezium  Shape = "invtrapezium"
	ShapeInvHouse      Shape = "invhouse"
	ShapeMDiamond      Shape = "Mdiamond"
	ShapeMSquare       Shape = "Msquare"
	ShapeMCircle       Shape = "Mcircle"
	ShapeRect          Shape = "rect"
	ShapeRectangle     Shape = "rectangle"
	ShapeSquare        Shape = "square"
	ShapeStar          Shape = "star"
	ShapeCylinder      Shape = "cylinder"
	ShapeNote          Shape = "note"
	ShapeTab           Shape = "tab"
	ShapeFolder        Shape = "folder"
	ShapeBox3D         Shape = "box3d"
	ShapeComponent     Shape = "component"
	ShapeCDS           Shape = "cds"
	ShapeAssembly      Shape = "assembly"
	ShapeSignature     Shape = "signature"
	ShapeRArrow        Shape = "rarrow"
	ShapeLArrow        Shape = "larrow"
	ShapePromoter      Shape = "promoter"
	ShapeRPromoter     Shape = "rpromoter"
	ShapeLPromoter     Shape = "lpromoter"
	ShapeRecord        Shape = "record"
	ShapeMrecord       Shape = "Mrecord"
)

type Style

type Style string
const (
	// For nodes and edges
	StyleSolid  Style = "solid"
	StyleBold   Style = "bold"
	StyleDashed Style = "dashed"
	StyleDotted Style = "dotted"
	StyleInvis  Style = "invis"

	// For nodes and clusters
	StyleFilled  Style = "filled"
	StyleStriped Style = "striped"
	StyleRounded Style = "rounded"

	// For nodes only
	StyleWedged    Style = "wedged"
	StyleDiagonals Style = "diagonals"

	// For edges only
	StyleTapered Style = "tapered"
)

type Subgraph

type Subgraph struct {
	Name      string
	Label     string
	Color     Color
	Style     Style
	Rank      Rank
	RankDir   RankDir
	NodeColor Color
	NodeStyle Style
	NodeShape Shape
	Nodes     []Node
	Edges     []Edge
	Subgraphs []Subgraph
}

Subgraph represents a subgraph.

func NewSubgraph

func NewSubgraph(name, label string, color Color, style Style, rank Rank, rankDir RankDir, nodeColor Color, nodeStyle Style, nodeShape Shape) Subgraph

NewSubgraph creates a new subgraph.

func (*Subgraph) AddEdge

func (s *Subgraph) AddEdge(edges ...Edge)

AddEdge adds a new edge to this subgraph.

func (*Subgraph) AddNode

func (s *Subgraph) AddNode(nodes ...Node)

AddNode adds a new node to this subgraph.

func (*Subgraph) AddSubgraph

func (s *Subgraph) AddSubgraph(subgraphs ...Subgraph)

AddSubgraph adds a new subgraph to this subgraph.

func (*Subgraph) DOT

func (s *Subgraph) DOT(indent int) string

DOT generates a DOT representation of the Subgraph object.

Jump to

Keyboard shortcuts

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