Documentation ¶
Overview ¶
Package dot implements an API to produce Graphviz dot language output.
Basic Graph creation:
g := dot.NewGraph("G") g.SetType(dot.DIGRAPH) ... g.AddEdge(dot.NewNode("A"), dot.NewNode("B")) ... fmt.Sprint(g)
Index ¶
- Variables
- func QuoteIfNecessary(s string) (result string)
- type Edge
- func (e Edge) Destination() *Node
- func (c *Edge) Get(attributeName string) string
- func (c *Edge) GetParentGraph() *Graph
- func (c Edge) Name() string
- func (c *Edge) Sequence() int
- func (e *Edge) Set(attributeName, attributeValue string) error
- func (c *Edge) SetParentGraph(g *Graph)
- func (e Edge) Source() *Node
- func (e Edge) String() string
- func (c *Edge) Type() string
- type Graph
- func (g *Graph) AddEdge(e *Edge)
- func (g *Graph) AddNode(n *Node)
- func (g *Graph) AddSubgraph(sg *SubGraph)
- func (c *Graph) Get(attributeName string) string
- func (c *Graph) GetParentGraph() *Graph
- func (g *Graph) GetRoot() (result *Graph)
- func (g *Graph) GetSubgraphs() (result []*SubGraph)
- func (c Graph) Name() string
- func (g *Graph) SameRank(nodes []string)
- func (c *Graph) Sequence() int
- func (g *Graph) Set(attributeName, attributeValue string) error
- func (g *Graph) SetGlobalEdgeAttr(attributeName, attributeValue string) error
- func (g *Graph) SetGlobalNodeAttr(attributeName, attributeValue string) error
- func (c *Graph) SetParentGraph(g *Graph)
- func (g *Graph) SetType(t GraphType)
- func (g Graph) String() string
- func (c *Graph) Type() string
- type GraphObject
- type GraphType
- type Node
- func (c *Node) Get(attributeName string) string
- func (c *Node) GetParentGraph() *Graph
- func (c Node) Name() string
- func (c *Node) Sequence() int
- func (n *Node) Set(attributeName, attributeValue string) error
- func (c *Node) SetParentGraph(g *Graph)
- func (n Node) String() string
- func (c *Node) Type() string
- type SubGraph
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AttributeError = errors.New("Invalid Attribute")
Functions ¶
func QuoteIfNecessary ¶
Types ¶
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
func (Edge) Destination ¶
func (*Edge) GetParentGraph ¶
func (c *Edge) GetParentGraph() *Graph
func (*Edge) SetParentGraph ¶
func (c *Edge) SetParentGraph(g *Graph)
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
func NewGraph ¶
Example ¶
package main import ( "fmt" "github.com/tmc/dot" ) func main() { g := dot.NewGraph("G") g.Set("label", "Example graph") n1, n2 := dot.NewNode("Node1"), dot.NewNode("Node2") n1.Set("color", "sienna") g.AddNode(n1) g.AddNode(n2) e := dot.NewEdge(n1, n2) e.Set("dir", "both") g.AddEdge(e) fmt.Println(g) }
Output: digraph G { graph [ label="Example graph"; ]; Node1 [color=sienna]; Node2; Node1 -> Node2 [ dir=both ] }
func (*Graph) AddSubgraph ¶
func (*Graph) GetParentGraph ¶
func (c *Graph) GetParentGraph() *Graph
func (*Graph) GetSubgraphs ¶
func (*Graph) SetGlobalEdgeAttr ¶
func (*Graph) SetGlobalNodeAttr ¶
func (*Graph) SetParentGraph ¶
func (c *Graph) SetParentGraph(g *Graph)
type GraphObject ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) GetParentGraph ¶
func (c *Node) GetParentGraph() *Graph
func (*Node) SetParentGraph ¶
func (c *Node) SetParentGraph(g *Graph)
type SubGraph ¶
type SubGraph struct {
Graph
}
func NewSubgraph ¶
func (*SubGraph) GetParentGraph ¶
func (c *SubGraph) GetParentGraph() *Graph
func (*SubGraph) SetParentGraph ¶
func (c *SubGraph) SetParentGraph(g *Graph)
Click to show internal directories.
Click to hide internal directories.