Documentation ¶
Overview ¶
Package graphviz provides a concrete prettyprinters.DigraphPrettyPrinter implementation for rendering directed graphs as Graphviz-compatible dot source files. It exports an interface, graphviz.PrintProvider, that allows users to provide general methods for rendering graphed data types into graphviz documents.
Index ¶
- type BasicProvider
- func (p BasicProvider) EdgeGetLabel(GraphEntity, GraphEntity) (pp.VisibleRenderable, error)
- func (p BasicProvider) EdgeGetProperties(GraphEntity, GraphEntity) PropertySet
- func (p BasicProvider) SubgraphMarker(GraphEntity) SubgraphMarkerKey
- func (p BasicProvider) VertexGetID(e GraphEntity) (pp.VisibleRenderable, error)
- func (p BasicProvider) VertexGetLabel(e GraphEntity) (pp.VisibleRenderable, error)
- func (p BasicProvider) VertexGetProperties(GraphEntity) PropertySet
- type GraphEntity
- type GraphIDProvider
- type Options
- type PrintProvider
- type Printer
- func (p *Printer) DrawEdge(g *graph.Graph, id1, id2 string) (pp.Renderable, error)
- func (p *Printer) DrawNode(g *graph.Graph, id string) (pp.Renderable, error)
- func (*Printer) FinishPP(*graph.Graph) (pp.Renderable, error)
- func (*Printer) FinishSubgraph(*graph.Graph, pp.SubgraphID) (pp.Renderable, error)
- func (p *Printer) GraphAttributes() string
- func (p *Printer) MarkNode(g *graph.Graph, id string) *pp.SubgraphMarker
- func (p *Printer) StartPP(*graph.Graph) (pp.Renderable, error)
- func (p *Printer) StartSubgraph(g *graph.Graph, startNode string, subgraphID pp.SubgraphID) (pp.Renderable, error)
- type PropertySet
- type SubgraphMarkerKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicProvider ¶
type BasicProvider struct{}
A BasicProvider is a basic PrintProvider for Graphviz that uses the value in the default format (%v) as the node label and id.
func (BasicProvider) EdgeGetLabel ¶
func (p BasicProvider) EdgeGetLabel(GraphEntity, GraphEntity) (pp.VisibleRenderable, error)
EdgeGetLabel provides a basic implementation leaves the edge unlabeled.
func (BasicProvider) EdgeGetProperties ¶
func (p BasicProvider) EdgeGetProperties(GraphEntity, GraphEntity) PropertySet
EdgeGetProperties provides a basic implementation that returns an empty property set.
func (BasicProvider) SubgraphMarker ¶
func (p BasicProvider) SubgraphMarker(GraphEntity) SubgraphMarkerKey
SubgraphMarker provides a basic implementation that returns a NOP.
func (BasicProvider) VertexGetID ¶
func (p BasicProvider) VertexGetID(e GraphEntity) (pp.VisibleRenderable, error)
VertexGetID provides a basic implementation that returns the %v quoted value of the node.
func (BasicProvider) VertexGetLabel ¶
func (p BasicProvider) VertexGetLabel(e GraphEntity) (pp.VisibleRenderable, error)
VertexGetLabel provides a basic implementation that returns the %v quoted value of the node (as with VertexGetID).
func (BasicProvider) VertexGetProperties ¶
func (p BasicProvider) VertexGetProperties(GraphEntity) PropertySet
VertexGetProperties provides a basic implementation that returns an empty property set.
type GraphEntity ¶
type GraphEntity struct { Name string // The canonical node ID Value interface{} // The value at the node }
GraphEntity defines the value at a given vertex, providing both it's canonical name and the untyped value associated with the vertex.
type GraphIDProvider ¶
type GraphIDProvider struct {
BasicProvider
}
A GraphIDProvider is a basic PrintProvider for Graphviz that uses the Node ID from the digraph as the Vertex ID and label.
func (GraphIDProvider) VertexGetID ¶
func (p GraphIDProvider) VertexGetID(e GraphEntity) (pp.VisibleRenderable, error)
VertexGetID provides a basic implementation that uses the ID from the graph to generate the VertexID.
func (GraphIDProvider) VertexGetLabel ¶
func (p GraphIDProvider) VertexGetLabel(e GraphEntity) (pp.VisibleRenderable, error)
VertexGetLabel provides a basic implementation that uses the ID from the graph to generate the Vertex Label.
type Options ¶
type Options struct { // Specifies the way that connections between verices are drawn. The default // is 'spline', other options include: 'line', 'orth', and 'none'. See // http://www.graphviz.org/doc/info/attrs.html#d:splines Splines string // Specifies the direction of the graph. See // http://www.graphviz.org/doc/info/attrs.html#d:rankdir for more information. Rankdir string }
Options specifies global graph options that can be configured for output. Arbitrary graphviz options are not supported.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns an Options struct with default values set.
type PrintProvider ¶
type PrintProvider interface { // Given a graph entity, this function shall return a unique ID that will be // used for the vertex. Note that this is not used for display, see // VertexGetLabel() for information on vertex displays. VertexGetID(GraphEntity) (pp.VisibleRenderable, error) // Defines the label associated with the vertex. This will be the name // applied to the vertex when it is drawn. Labels are stored in the vertex // attribute list automatically. The 'label' parameter should therefore not // be returned as part of VertexGetProperties(). VertexGetLabel(GraphEntity) (pp.VisibleRenderable, error) // VertexGetProperties allows the PrintProvider to provide additional // attributes to a given vertex. Note that the 'label' attribute is special // and should not be returned as part of this call. VertexGetProperties(GraphEntity) PropertySet // Defines the label associated with the edge formed between two graph // entities. This will be the name applied to the edge when it is drawn. EdgeGetLabel(GraphEntity, GraphEntity) (pp.VisibleRenderable, error) // EdgeGetProperties allows the PrintProvider to provide additional // attributes to a given edge. Note that the 'label' attribute is special // and should not be returned as part of this call. EdgeGetProperties(GraphEntity, GraphEntity) PropertySet // Allows the underlying provider to identify vertices that are the beginning // of a subgraph. The function should return one of: // SubgraphMarkerStart // SubgraphMarkerEnd // SubgraphMarkerNOP // in order to specify the vertexs' relation to subgraphs. SubgraphMarker(GraphEntity) SubgraphMarkerKey }
PrintProvider allows specific serializable types to be rendered as a Graphviz document.
func DefaultProvider ¶
func DefaultProvider() PrintProvider
DefaultProvider returns an empty BasicProvider as a convenience
func IDProvider ¶
func IDProvider() PrintProvider
IDProvider is a convenience function to generate a GraphIDProvider.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer is a DigraphPrettyPrinter implementation for drawing graphviz compatible DOT source code from a digraph.
func New ¶
func New(opts Options, provider PrintProvider) *Printer
New will create a new graphviz.Printer with the options and print provider specified.
func (*Printer) DrawEdge ¶
DrawEdge prints edge data in a fashion similar to DrawNode. It will return a visible Renderable IFF the source and destination vertices are visible.
func (*Printer) DrawNode ¶
DrawNode prints node data by calling VertexGetID(), VertexGetLabel() and VertexGetProperties() on the associated print provider. It will return a visible Renderable IFF the underlying VertexID is renderable.
func (*Printer) FinishSubgraph ¶
func (*Printer) FinishSubgraph(*graph.Graph, pp.SubgraphID) (pp.Renderable, error)
FinishSubgraph provides the closing '}' for a subgraph
func (*Printer) GraphAttributes ¶
GraphAttributes returns a string containing all of the global graph attributes specified in Options.
func (*Printer) MarkNode ¶
MarkNode will call SubgraphMarker() on the print provider to determine whether the current node is the beginning of a subgraph.
func (*Printer) StartSubgraph ¶
func (p *Printer) StartSubgraph(g *graph.Graph, startNode string, subgraphID pp.SubgraphID) (pp.Renderable, error)
StartSubgraph returns a string with the beginning of the subgraph cluster
type PropertySet ¶
PropertySet is a map of graphviz compatible node or edge options and their values. See http://www.graphviz.org/doc/info/attrs.html for a list of supported attributes. Node that graph and subgraph attributes are not currently supported.
type SubgraphMarkerKey ¶
type SubgraphMarkerKey int
SubgraphMarkerKey is a type alias for an integer and represents the state values for subgraph tracking.
const ( // SubgraphMarkerStart specifies that the current node is the beginning of a // subgraph. SubgraphMarkerStart SubgraphMarkerKey = iota // SubgraphMarkerEnd pecifies that the current node is the end of a subgraph. SubgraphMarkerEnd // SubgraphMarkerNOP pecifies that the current node should not change the // subgraph state. SubgraphMarkerNOP )