Documentation ¶
Overview ¶
Package gographviz provides parsing for the DOT grammar into an abstract syntax tree representing a graph, analysis of the abstract syntax tree into a more usable structure, and writing back of this structure into the DOT format.
Index ¶
- func Analyse(graph *ast.Graph, g Interface)
- func Parse(buf []byte) (*ast.Graph, error)
- type Attrs
- type Edge
- type Edges
- type Escape
- func (this *Escape) AddAttr(parentGraph string, field, value string)
- func (this *Escape) AddEdge(src, dst string, directed bool, attrs map[string]string)
- func (this *Escape) AddNode(parentGraph string, name string, attrs map[string]string)
- func (this *Escape) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string)
- func (this *Escape) AddSubGraph(parentGraph string, name string, attrs map[string]string)
- func (this *Escape) SetName(name string)
- type Graph
- func (this *Graph) AddAttr(parentGraph string, field string, value string)
- func (this *Graph) AddEdge(src, dst string, directed bool, attrs map[string]string)
- func (this *Graph) AddNode(parentGraph string, name string, attrs map[string]string)
- func (this *Graph) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string)
- func (this *Graph) AddSubGraph(parentGraph string, name string, attrs map[string]string)
- func (this *Graph) IsNode(name string) bool
- func (this *Graph) IsSubGraph(name string) bool
- func (this *Graph) SetDir(dir bool)
- func (this *Graph) SetName(name string)
- func (this *Graph) SetStrict(strict bool)
- func (g *Graph) String() string
- func (g *Graph) WriteAst() *ast.Graph
- type Interface
- type Node
- type Nodes
- type Relations
- type SubGraph
- type SubGraphs
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attrs ¶
Represents attributes for an Edge, Node or Graph.
func (Attrs) SortedNames ¶
type Edges ¶
type Edges struct { SrcToDsts map[string]map[string]*Edge DstToSrcs map[string]map[string]*Edge Edges []*Edge }
Represents a set of Edges.
type Escape ¶
type Escape struct {
Interface
}
func (*Escape) AddPortEdge ¶
func (*Escape) AddSubGraph ¶
type Graph ¶
type Graph struct { Attrs Attrs Name string Directed bool Strict bool Nodes *Nodes Edges *Edges SubGraphs *SubGraphs Relations *Relations }
The analysed representation of the Graph parsed from the DOT format.
func NewGraph ¶
func NewGraph() *Graph
Creates a new empty graph, ready to be populated.
Example ¶
g := NewGraph() g.SetName("G") g.SetDir(true) g.AddNode("G", "Hello", nil) g.AddNode("G", "World", nil) g.AddEdge("Hello", "World", true, nil) s := g.String() fmt.Println(s)
Output: digraph G { Hello->World; Hello; World; }
func (*Graph) AddEdge ¶
Adds an edge to the graph from node src to node dst. This does not imply the adding of missing nodes.
func (*Graph) AddNode ¶
Adds a node to a graph/subgraph. If not subgraph exists use the name of the main graph. This does not imply the adding of a missing subgraph.
func (*Graph) AddPortEdge ¶
func (this *Graph) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string)
Adds an edge to the graph from node src to node dst. srcPort and dstPort are the port the node ports, leave as empty strings if it is not required. This does not imply the adding of missing nodes.
func (*Graph) AddSubGraph ¶
Adds a subgraph to a graph/subgraph.
func (*Graph) IsSubGraph ¶
type Interface ¶
type Interface interface { SetStrict(strict bool) SetDir(directed bool) SetName(name string) AddPortEdge(src, srcPort, dst, dstPort string, directed bool, attrs map[string]string) AddEdge(src, dst string, directed bool, attrs map[string]string) AddNode(parentGraph string, name string, attrs map[string]string) AddAttr(parentGraph string, field, value string) AddSubGraph(parentGraph string, name string, attrs map[string]string) String() string }
Implementing this interface allows you to parse the graph into your own structure.
func NewAnalysedGraph ¶
Creates a Graph structure by analysing an Abstract Syntax Tree representing a parsed graph.
type Nodes ¶
Represents a set of Nodes.
type Relations ¶
type Relations struct { ParentToChildren map[string]map[string]bool ChildToParents map[string]map[string]bool }
Represents the relations between graphs and nodes. Each node belongs the main graph or a subgraph.
func (*Relations) SortedChildren ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Abstract Syntax Tree representing the DOT grammar
|
Abstract Syntax Tree representing the DOT grammar |
A parser for the DOT grammar.
|
A parser for the DOT grammar. |
A scanner for the DOT grammar that has been derived from the standard golang scanner with extra added literals.
|
A scanner for the DOT grammar that has been derived from the standard golang scanner with extra added literals. |