Documentation
¶
Index ¶
- Variables
- type Attribute
- type AttributesMap
- type ClusterOption
- type Edge
- type Graph
- func (g *Graph) AddToSameRank(group string, nodes ...Node)
- func (g *Graph) Edge(fromNode, toNode *Node, withAttrs ...func(*AttributesMap)) *Edge
- func (g *Graph) FindEdges(fromNode, toNode Node) (found []Edge)
- func (g *Graph) FindNodeByID(id string) (found *Node)
- func (g *Graph) FindNodeByLabel(label string) (found *Node)
- func (g *Graph) FindSubgraph(id string) (*Graph, bool)
- func (g *Graph) FindSubgraphByLabel(label string) (*Graph, bool)
- func (g *Graph) ID(newID string) *Graph
- func (g *Graph) IndentedWrite(w *IndentWriter)
- func (g *Graph) Label(label string) *Graph
- func (g *Graph) NewSubgraph() *Graph
- func (g *Graph) Node(withAttrs ...func(*AttributesMap)) *Node
- func (g *Graph) NodeBaseAttrs() *AttributesMap
- func (g *Graph) NodeWithID(id string, withAttrs ...func(*AttributesMap)) *Node
- func (g *Graph) Root() *Graph
- func (g *Graph) String() string
- func (g *Graph) VisitNodes(callback func(node *Node) (done bool))
- func (g *Graph) Write(w io.Writer)
- type GraphOption
- type GraphTypeOption
- type HTML
- type IndentWriter
- func (i *IndentWriter) BackIndent()
- func (i *IndentWriter) Indent()
- func (i *IndentWriter) IndentWhile(block func())
- func (i *IndentWriter) NewLine()
- func (i *IndentWriter) NewLineIndentWhile(block func())
- func (i *IndentWriter) Write(data []byte) (n int, err error)
- func (i *IndentWriter) WriteString(s string) (n int, err error)
- type Literal
- type Node
Constants ¶
This section is empty.
Variables ¶
var ( // Strict defines a `strict` Graph type Strict = GraphTypeOption{"strict"} // Undirected defines a `graph` Graph type Undirected = GraphTypeOption{"graph"} // Directed defines a `digraph` Graph type Directed = GraphTypeOption{"digraph"} // Sub defines a `subgraph` Graph type Sub = GraphTypeOption{"subgraph"} )
Functions ¶
This section is empty.
Types ¶
type Attribute ¶ added in v0.4.1
type Attribute func(*AttributesMap)
type AttributesMap ¶
type AttributesMap struct {
// contains filtered or unexported fields
}
AttributesMap holds attribute=value pairs.
func (*AttributesMap) Attr ¶
func (a *AttributesMap) Attr(label string, value interface{}) *AttributesMap
Attr sets the value for an attribute (unless empty).
func (*AttributesMap) Delete ¶
func (a *AttributesMap) Delete(key string)
Delete removes the attribute value at key, if any
func (*AttributesMap) Value ¶
func (a *AttributesMap) Value(label string) interface{}
Value return the value added for this label.
type ClusterOption ¶
type ClusterOption struct{}
ClusterOption mark a graph as cluster
func (ClusterOption) Apply ¶
func (o ClusterOption) Apply(g *Graph)
Apply enforces the Graph as cluster
type Edge ¶
type Edge struct {
AttributesMap
// contains filtered or unexported fields
}
Edge represents a graph edge between two Nodes.
func (*Edge) Attrs ¶ added in v0.3.0
func (e *Edge) Attrs() *AttributesMap
Attrs returns the node attributes
type Graph ¶
type Graph struct {
AttributesMap
// contains filtered or unexported fields
}
Graph represents a dot graph with nodes and edges.
func NewGraph ¶
func NewGraph(options ...GraphOption) *Graph
NewGraph return a new initialized Graph.
func (*Graph) AddToSameRank ¶
AddToSameRank adds the given nodes to the specified rank group, forcing them to be rendered in the same row
func (*Graph) Edge ¶
func (g *Graph) Edge(fromNode, toNode *Node, withAttrs ...func(*AttributesMap)) *Edge
Edge creates a new edge between two nodes. Eventually specify optional attributes using the `withAttrs` functions. Nodes can be have multiple edges to the same other node (or itself).
func (*Graph) FindEdges ¶
FindEdges finds all edges in the graph that go from the fromNode to the toNode. Otherwise, returns an empty slice.
func (*Graph) FindNodeByID ¶
FindNodeByID returns a node by its identifier.
func (*Graph) FindNodeByLabel ¶ added in v0.3.0
FindNodeByLabel returns a node by its label.
func (*Graph) FindSubgraph ¶
FindSubgraph returns the subgraph of the graph or one from its parents.
func (*Graph) FindSubgraphByLabel ¶ added in v0.4.1
FindSubgraphByLabel returns the subgraph of the graph or one from its parents.
func (*Graph) IndentedWrite ¶
func (g *Graph) IndentedWrite(w *IndentWriter)
IndentedWrite write the graph to a writer using simple TAB indentation.
func (*Graph) NewSubgraph ¶ added in v0.4.1
Subgraph creates a new subgraph.
func (*Graph) Node ¶
func (g *Graph) Node(withAttrs ...func(*AttributesMap)) *Node
Node creates a new node with an autogenerated identifier. Eventually specify optional attributes using the `withAttrs` functions. The node will have a label attribute with the id as its value. Use Label() to overwrite this.
func (*Graph) NodeBaseAttrs ¶ added in v0.4.1
func (g *Graph) NodeBaseAttrs() *AttributesMap
NodeBaseAttrs returns the node global attributes.
func (*Graph) NodeWithID ¶ added in v0.3.0
func (g *Graph) NodeWithID(id string, withAttrs ...func(*AttributesMap)) *Node
NodeWithID creates a new node with the specified identifier. Eventually specify optional attributes using the `withAttrs` functions. The node will have a label attribute with the id as its value. Use Label() to overwrite this.
func (*Graph) VisitNodes ¶
VisitNodes visits all nodes recursively
type GraphOption ¶
type GraphOption interface {
Apply(*Graph)
}
GraphOption is a Graph configuration option.
type GraphTypeOption ¶
type GraphTypeOption struct {
Name string
}
GraphTypeOption sets the graph type
func (GraphTypeOption) Apply ¶
func (o GraphTypeOption) Apply(g *Graph)
Apply enforces the Graph type
type HTML ¶
type HTML string
HTML renders the provided content as graphviz HTML. Use of this type is only valid for some attributes, like the 'label' attribute.
type IndentWriter ¶
type IndentWriter struct {
// contains filtered or unexported fields
}
IndentWriter is a writer with indentation.
func NewIndentWriter ¶
func NewIndentWriter(w io.Writer) *IndentWriter
NewIndentWriter returns a IndentWriter from a io.Writer.
func (*IndentWriter) BackIndent ¶
func (i *IndentWriter) BackIndent()
BackIndent decrements the current indentation level.
func (*IndentWriter) Indent ¶
func (i *IndentWriter) Indent()
Indent writes a tab `\t` to the writer
func (*IndentWriter) IndentWhile ¶
func (i *IndentWriter) IndentWhile(block func())
IndentWhile writes an indented block.
func (*IndentWriter) NewLineIndentWhile ¶
func (i *IndentWriter) NewLineIndentWhile(block func())
NewLineIndentWhile writes an indented block between new line chars `\n`.
func (*IndentWriter) Write ¶
func (i *IndentWriter) Write(data []byte) (n int, err error)
Write makes it an io.Writer
func (*IndentWriter) WriteString ¶
func (i *IndentWriter) WriteString(s string) (n int, err error)
WriteString writes an indented string
type Literal ¶
type Literal string
Literal renders the provided value as is, without adding enclosing quotes, escaping newlines, quotations marks or any other characters. For example:
node.Attr("label", Literal(`"left-justified text\l"`))
allows you to left-justify the label (due to the \l at the end). The caller is responsible for enclosing the value in quotes and for proper escaping of special characters.
type Node ¶
type Node struct {
AttributesMap
// contains filtered or unexported fields
}
Node represents a dot Node.
func (*Node) Attrs ¶ added in v0.3.0
func (n *Node) Attrs() *AttributesMap
Attrs returns the node attributes
