package ast

import "gonum.org/v1/gonum/graph/formats/dot/ast"

Package ast declares the types used to represent abstract syntax trees of Graphviz DOT graphs.

Index

Types

type Attr

type Attr struct {
	// Attribute key.
	Key string
	// Attribute value.
	Val string
}

An Attr represents an attribute.

Examples.

rank=same

func (*Attr) String

func (a *Attr) String() string

String returns the string representation of the attribute.

type AttrStmt

type AttrStmt struct {
	// Graph component kind to which the attributes are assigned.
	Kind Kind
	// Attributes.
	Attrs []*Attr
}

An AttrStmt represents an attribute statement.

Examples.

graph [rankdir=LR]
node [color=blue fillcolor=red]
edge [minlen=1]

func (*AttrStmt) String

func (a *AttrStmt) String() string

String returns the string representation of the attribute statement.

type CompassPoint

type CompassPoint uint

CompassPoint specifies the set of compass points.

const (
	CompassPointNone      CompassPoint = iota //
	CompassPointNorth                         // n
	CompassPointNorthEast                     // ne
	CompassPointEast                          // e
	CompassPointSouthEast                     // se
	CompassPointSouth                         // s
	CompassPointSouthWest                     // sw
	CompassPointWest                          // w
	CompassPointNorthWest                     // nw
	CompassPointCenter                        // c
	CompassPointDefault                       // _
)

Compass points.

func (CompassPoint) String

func (c CompassPoint) String() string

String returns the string representation of the compass point.

type Edge

type Edge struct {
	// Directed edge.
	Directed bool
	// Destination vertex.
	Vertex Vertex
	// Outgoing edge; or nil if none.
	To *Edge
}

An Edge represents an edge between two vertices.

func (*Edge) String

func (e *Edge) String() string

String returns the string representation of the edge.

type EdgeStmt

type EdgeStmt struct {
	// Source vertex.
	From Vertex
	// Outgoing edge.
	To *Edge
	// Edge attributes.
	Attrs []*Attr
}

An EdgeStmt represents an edge statement.

Examples.

A -> B
A -> {B C}
A -> B -> C

func (*EdgeStmt) String

func (e *EdgeStmt) String() string

String returns the string representation of the edge statement.

type File

type File struct {
	// Graphs.
	Graphs []*Graph
}

A File represents a DOT file.

Examples.

digraph G {
   A -> B
}
graph H {
   C - D
}

func (*File) String

func (f *File) String() string

String returns the string representation of the file.

type Graph

type Graph struct {
	// Strict graph; multi-edges forbidden.
	Strict bool
	// Directed graph.
	Directed bool
	// Graph ID; or empty if anonymous.
	ID string
	// Graph statements.
	Stmts []Stmt
}

A Graph represents a directed or an undirected graph.

Examples.

digraph G {
   A -> {B C}
   B -> C
}

func (*Graph) String

func (g *Graph) String() string

String returns the string representation of the graph.

type Kind

type Kind uint

Kind specifies the set of graph components to which attribute statements may be assigned.

const (
	GraphKind Kind = iota // graph
	NodeKind              // node
	EdgeKind              // edge
)

Graph component kinds.

func (Kind) String

func (k Kind) String() string

String returns the string representation of the graph component kind.

type Node

type Node struct {
	// Node ID.
	ID string
	// Node port; or nil if none.
	Port *Port
}

A Node represents a node vertex.

Examples.

A
A:nw

func (*Node) String

func (n *Node) String() string

String returns the string representation of the node.

type NodeStmt

type NodeStmt struct {
	// Node.
	Node *Node
	// Node attributes.
	Attrs []*Attr
}

A NodeStmt represents a node statement.

Examples.

A [color=blue]

func (*NodeStmt) String

func (e *NodeStmt) String() string

String returns the string representation of the node statement.

type Port

type Port struct {
	// Port ID; or empty if none.
	ID string
	// Compass point.
	CompassPoint CompassPoint
}

A Port specifies where on a node an edge should be aimed.

func (*Port) String

func (p *Port) String() string

String returns the string representation of the port.

type Stmt

type Stmt interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

A Stmt represents a statement, and has one of the following underlying types.

*NodeStmt
*EdgeStmt
*AttrStmt
*Attr
*Subgraph

type Subgraph

type Subgraph struct {
	// Subgraph ID; or empty if none.
	ID string
	// Subgraph statements.
	Stmts []Stmt
}

A Subgraph represents a subgraph vertex.

Examples.

subgraph S {A B C}

func (*Subgraph) String

func (s *Subgraph) String() string

String returns the string representation of the subgraph.

type Vertex

type Vertex interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

A Vertex represents a vertex, and has one of the following underlying types.

*Node
*Subgraph

Source Files

ast.go doc.go

Version
v0.15.1 (latest)
Published
Aug 16, 2024
Platform
linux/amd64
Imports
2 packages
Last checked
20 hours ago

Tools for package owners.