Documentation
¶
Index ¶
- Variables
- func QuoteIfNecessary(s string) string
- type AttributeError
- type Edge
- func (e *Edge) Clone() *Edge
- func (e *Edge) Destination() *Node
- func (e *Edge) Equals(other *Edge) bool
- func (e *Edge) Get(key string) string
- func (e *Edge) Name() string
- func (e *Edge) Sequence() int
- func (e *Edge) Set(key, value string) error
- func (e *Edge) SetSequence(seq int)
- func (e *Edge) Source() *Node
- func (e *Edge) String() string
- func (e *Edge) Type() string
- type Graph
- func (g *Graph) AddEdge(e *Edge) (*Edge, error)
- func (g *Graph) AddNode(n *Node) (*Node, error)
- func (g *Graph) AddSubgraph(sg *SubGraph) (*SubGraph, error)
- func (g *Graph) BFS(startNode string, visitor func(*Node))
- func (g *Graph) Clone() *Graph
- func (g *Graph) DFS(startNode string, visitor func(*Node))
- func (g *Graph) Diff(other *Graph) (*Graph, error)
- func (g *Graph) Equals(other *Graph) bool
- func (g *Graph) ExportDOT(w io.Writer) error
- func (g *Graph) ExportJSON(w io.Writer) error
- func (g *Graph) Get(key string) string
- func (g *Graph) GetAverageDegree() float64
- func (g *Graph) GetDegree(nodeName string) int
- func (g *Graph) GetDensity() float64
- func (g *Graph) GetEdgeCount() int
- func (g *Graph) GetInDegree(nodeName string) int
- func (g *Graph) GetNodeCount() int
- func (g *Graph) GetOutDegree(nodeName string) int
- func (g *Graph) GetSubgraphCount() int
- func (g *Graph) GetSubgraphs() []*SubGraph
- func (g *Graph) MarshalJSON() ([]byte, error)
- func (g *Graph) Merge(other *Graph) error
- func (g *Graph) Optimize()
- func (g *Graph) RemoveEdge(src, dst string)
- func (g *Graph) RemoveNode(nodeName string)
- func (g *Graph) RemoveSubgraph(name string)
- func (g *Graph) SameRank(nodes []string)
- func (g *Graph) Set(key, value string) error
- func (g *Graph) SetGlobalEdgeAttr(key, value string) error
- func (g *Graph) SetGlobalNodeAttr(key, value string) error
- func (g *Graph) SetStrict(strict bool) *Graph
- func (g *Graph) SetType(t GraphType) error
- func (g *Graph) ShortestPath(start, end *Node) ([]*Node, error)
- func (g *Graph) String() string
- func (g *Graph) ToPNG(filename string) error
- func (g *Graph) ToSVG(filename string) error
- func (g *Graph) TopologicalSort() ([]*Node, error)
- func (g *Graph) UnmarshalJSON(data []byte) error
- func (g *Graph) Validate() error
- type GraphObject
- type GraphType
- type Node
- func (n *Node) Clone() *Node
- func (n *Node) Equals(other *Node) bool
- func (n *Node) Get(key string) string
- func (n *Node) Name() string
- func (n *Node) Sequence() int
- func (n *Node) Set(key, value string) error
- func (n *Node) SetSequence(seq int)
- func (n *Node) String() string
- func (n *Node) Type() string
- type Sequenceable
- type SubGraph
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilNode = errors.New("cannot add nil node") ErrEmptyNodeName = errors.New("node name cannot be empty") ErrDuplicateNode = errors.New("node with this name already exists") ErrNilEdge = errors.New("cannot add nil edge") ErrInvalidEdge = errors.New("edge must have both source and destination nodes") ErrNodeNotFound = errors.New("node not found in the graph") ErrNilSubgraph = errors.New("cannot add nil subgraph") ErrEmptySubgraphName = errors.New("subgraph name cannot be empty") ErrDuplicateSubgraph = errors.New("subgraph with this name already exists") ErrInvalidGraphType = errors.New("invalid graph type") ErrUnsupportedOperation = errors.New("operation not supported for this graph type") ErrCycleDetected = errors.New("graph contains a cycle") ErrNoPath = errors.New("no path exists between the given nodes") ErrDOTParsingFailed = errors.New("failed to parse DOT input") ErrGraphvizNotFound = errors.New("Graphviz tools not found in system PATH") ErrInvalidNodeAttribute = errors.New("invalid node attribute") ErrInvalidEdgeAttribute = errors.New("invalid edge attribute") ErrInvalidGraphAttribute = errors.New("invalid graph attribute") )
Functions ¶
func QuoteIfNecessary ¶
Types ¶
type AttributeError ¶
Error type for invalid attributes
func (AttributeError) Error ¶
func (e AttributeError) Error() string
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
func (*Edge) Destination ¶
func (*Edge) SetSequence ¶
type Graph ¶
Graph represents a graph in the DOT language.
func NewGraph ¶
NewGraph creates a new graph with the given name.
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) GetAverageDegree ¶
func (*Graph) GetDensity ¶
func (*Graph) GetEdgeCount ¶
func (*Graph) GetInDegree ¶
func (*Graph) GetNodeCount ¶
func (*Graph) GetOutDegree ¶
func (*Graph) GetSubgraphCount ¶
func (*Graph) GetSubgraphs ¶
func (*Graph) MarshalJSON ¶
func (*Graph) RemoveEdge ¶
func (*Graph) RemoveNode ¶
func (*Graph) RemoveSubgraph ¶
func (*Graph) SetGlobalEdgeAttr ¶
func (*Graph) SetGlobalNodeAttr ¶
func (*Graph) TopologicalSort ¶
func (*Graph) UnmarshalJSON ¶
type GraphObject ¶
type GraphType ¶
type GraphType int
GraphType represents the type of a graph.
func GraphTypeFromString ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) SetSequence ¶
type Sequenceable ¶
type SubGraph ¶
type SubGraph struct {
Graph
// contains filtered or unexported fields
}
func NewSubgraph ¶
func (*SubGraph) SetSequence ¶
Click to show internal directories.
Click to hide internal directories.