dot

package
v1.4.4-alpha1202-loadi... Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Shape     = "shape"
	Style     = "style"
	Color     = "color"
	FillColor = "fillcolor"
	FontName  = "fontname"
	FontSize  = "fontsize"
	FontColor = "fontcolor"
	NodeSep   = "nodesep"
)

Common attribute names

View Source
const (
	ShapeBox       = "box"
	ShapePolygon   = "polygon"
	ShapeEllipse   = "ellipse"
	ShapeOval      = "oval"
	ShapeCircle    = "circle"
	ShapePoint     = "point"
	ShapeEgg       = "egg"
	ShapeTriangle  = "triangle"
	ShapeNone      = "none"
	ShapeDiamond   = "diamond"
	ShapeRectangle = "rectangle"
	ShapeSquare    = "square"
)

Common values for shape attribute

View Source
const (
	StyleSolid   = "solid"
	StyleDashed  = "dashed"
	StyleDotted  = "dotted"
	StyleBold    = "bold"
	StyleRounded = "rounded"
	StyleFilled  = "filled"
	StyleStriped = "striped"
)

Common values for style attribute

Variables

This section is empty.

Functions

func CreateNode

func CreateNode(id int, label string) node

func DotGraphToAsciiArt

func DotGraphToAsciiArt(t string) (string, error)

func GraphPathNext

func GraphPathNext(g *Graph, nodeId int) [][]string

func GraphPathPrev

func GraphPathPrev(g *Graph, nodeId int) [][]string

func GraphPathPrevWithFilter

func GraphPathPrevWithFilter(g *Graph, nodeId int, filter func(edge *Edge) bool) [][]string

func NodeName

func NodeName(id int) string

func ShowDotGraphToAsciiArt

func ShowDotGraphToAsciiArt(t string) (string, error)

Types

type Edge

type Edge struct {
	Label string
	// contains filtered or unexported fields
}

func CreateEdge

func CreateEdge(from, to *node, label string) Edge

func (Edge) Attribute

func (e Edge) Attribute(name string) string

func (Edge) From

func (e Edge) From() *node

func (Edge) To

func (e Edge) To() *node

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph represents a set of nodes, edges and attributes that can be translated to DOT language.

func New

func New() *Graph

func (*Graph) AddDashEdge

func (g *Graph) AddDashEdge(from, to int, label string) int

AddDashEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge. style

func (*Graph) AddDashEdgeWithoutArrowHead

func (g *Graph) AddDashEdgeWithoutArrowHead(from, to int, label string) int

AddDashEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge. style

func (*Graph) AddEdge

func (g *Graph) AddEdge(from, to int, label string) int

AddEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge.

func (*Graph) AddEdgeByLabel

func (g *Graph) AddEdgeByLabel(from, to string, label ...string) int

AddEdgeByLabel adds a new edge between the nodes with the given

func (*Graph) AddEdgeInRoot

func (g *Graph) AddEdgeInRoot(from, to string)

func (*Graph) AddEdgeWithSubGraph

func (g *Graph) AddEdgeWithSubGraph(from, to string, subGraph string)

func (*Graph) AddNode

func (g *Graph) AddNode(label string) int

AddNode adds a new node with the given label and returns its id.

func (*Graph) CreateSubGraph

func (g *Graph) CreateSubGraph(label string) *Graph

func (*Graph) DefaultEdgeAttribute

func (g *Graph) DefaultEdgeAttribute(name, value string)

DefaultEdgeAttribute sets an attribute for all edges by default.

func (*Graph) DefaultNodeAttribute

func (g *Graph) DefaultNodeAttribute(name, value string)

DefaultNodeAttribute sets an attribute for all nodes by default.

func (*Graph) DrawMultipleEdges

func (g *Graph) DrawMultipleEdges()

DrawMultipleEdges causes multiple edges between same pair of nodes to be drawn separately. By default, for a given pair of nodes, only the edge that was last added to the graph is drawn.

func (*Graph) EdgeAttribute

func (g *Graph) EdgeAttribute(id int, name, value string)

EdgeAttribute sets an attribute for the specified edge.

func (*Graph) FindNode

func (g *Graph) FindNode(name string) *node

func (*Graph) GenerateDOT

func (g *Graph) GenerateDOT(w io.Writer)

func (*Graph) GenerateDOTString

func (g *Graph) GenerateDOTString() string

func (*Graph) GetAllEdgeLabels

func (g *Graph) GetAllEdgeLabels(fromLabel, toLabel string) []string

GetAllEdgeLabels returns all labels of edges between two nodes

func (*Graph) GetAllEdges

func (g *Graph) GetAllEdges() []*Edge

GetAllEdges returns all edges in the graph as a slice of edge info

func (*Graph) GetAllNodes

func (g *Graph) GetAllNodes() []string

GetAllNodes returns all node labels in the graph

func (*Graph) GetEdge

func (g *Graph) GetEdge(id int) *Edge

func (*Graph) GetEdgeLabel

func (g *Graph) GetEdgeLabel(fromLabel, toLabel string) string

GetEdgeLabel returns the label of the edge between two nodes If multiple edges exist, returns the first one found

func (*Graph) GetEdges

func (g *Graph) GetEdges(from, to int) []int

GetEdges returns the ids of the edges between the given nodes.

func (*Graph) GetNodeByID

func (g *Graph) GetNodeByID(id int) *node

func (*Graph) GetNodeLabel

func (g *Graph) GetNodeLabel(nodeLabel string) string

GetNodeLabel returns the label of a node by its label name

func (*Graph) GetNodesByLabel

func (g *Graph) GetNodesByLabel(label string) []*node

func (*Graph) GetOrCreateNode

func (g *Graph) GetOrCreateNode(label string) int

GetOrCreateNode returns the id of the node with the given label if it

func (*Graph) GetOrCreateNodeWithSubGraph

func (g *Graph) GetOrCreateNodeWithSubGraph(node string, subGraph string) int

func (*Graph) GetOrCreateSubGraph

func (g *Graph) GetOrCreateSubGraph(label string) *Graph

func (*Graph) GraphAttribute

func (g *Graph) GraphAttribute(name, value string)

GraphAttribute sets an attribute for the graph

func (*Graph) HasEdge

func (g *Graph) HasEdge(n1, n2 *node) bool

func (*Graph) HasEdgeContainLabel

func (g *Graph) HasEdgeContainLabel(fromLabel, toLabel, expectedLabel string) bool

func (*Graph) HasEdgeWithLabel

func (g *Graph) HasEdgeWithLabel(fromLabel, toLabel, expectedLabel string) bool

HasEdgeWithLabel checks if there is an edge between two nodes with the specified label

func (*Graph) IsConnected

func (g *Graph) IsConnected(fromLabel, toLabel string) bool

IsConnected checks if there is a path from node 'from' to node 'to' Uses depth-first search to find connectivity

func (*Graph) IsNeighbor

func (g *Graph) IsNeighbor(node1, node2 string) bool

IsNeighbor checks if two nodes are directly connected (neighbors) Returns true if there is a direct edge between the two nodes, false otherwise

func (*Graph) IsSubGraph

func (g *Graph) IsSubGraph() bool

func (*Graph) MakeDirected

func (g *Graph) MakeDirected()

MakeDirected makes the graph a directed graph. By default, a new graph is undirected

func (*Graph) MakeSameRank

func (g *Graph) MakeSameRank(node1, node2 int, others ...int)

MakeSameRank causes the specified nodes to be drawn on the same rank. Only effective when using the dot tool.

func (*Graph) NodeAttribute

func (g *Graph) NodeAttribute(id int, name, value string)

NodeAttribute sets an attribute for the specified node.

func (*Graph) NodeExisted

func (g *Graph) NodeExisted(label string) (int, bool)

NodeExisted returns the id of the node with the given label if it

func (*Graph) Root

func (g *Graph) Root() *Graph

func (*Graph) SetNode

func (g *Graph) SetNode(id int, label string)

func (*Graph) SetTitle

func (g *Graph) SetTitle(title string)

SetTitle sets a title for the graph.

Jump to

Keyboard shortcuts

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