Documentation
¶
Index ¶
- Constants
- func CreateNode(id int, label string) node
- func DotGraphToAsciiArt(t string) (string, error)
- func GraphPathNext(g *Graph, nodeId int) [][]string
- func GraphPathPrev(g *Graph, nodeId int) [][]string
- func GraphPathPrevWithFilter(g *Graph, nodeId int, filter func(edge *Edge) bool) [][]string
- func NodeName(id int) string
- func ShowDotGraphToAsciiArt(t string) (string, error)
- type Edge
- type Graph
- func (g *Graph) AddDashEdge(from, to int, label string) int
- func (g *Graph) AddDashEdgeWithoutArrowHead(from, to int, label string) int
- func (g *Graph) AddEdge(from, to int, label string) int
- func (g *Graph) AddEdgeByLabel(from, to string, label ...string) int
- func (g *Graph) AddEdgeInRoot(from, to string)
- func (g *Graph) AddEdgeWithSubGraph(from, to string, subGraph string)
- func (g *Graph) AddNode(label string) int
- func (g *Graph) CreateSubGraph(label string) *Graph
- func (g *Graph) DefaultEdgeAttribute(name, value string)
- func (g *Graph) DefaultNodeAttribute(name, value string)
- func (g *Graph) DrawMultipleEdges()
- func (g *Graph) EdgeAttribute(id int, name, value string)
- func (g *Graph) FindNode(name string) *node
- func (g *Graph) GenerateDOT(w io.Writer)
- func (g *Graph) GenerateDOTString() string
- func (g *Graph) GetAllEdgeLabels(fromLabel, toLabel string) []string
- func (g *Graph) GetAllEdges() []*Edge
- func (g *Graph) GetAllNodes() []string
- func (g *Graph) GetEdge(id int) *Edge
- func (g *Graph) GetEdgeLabel(fromLabel, toLabel string) string
- func (g *Graph) GetEdges(from, to int) []int
- func (g *Graph) GetNodeByID(id int) *node
- func (g *Graph) GetNodeLabel(nodeLabel string) string
- func (g *Graph) GetNodesByLabel(label string) []*node
- func (g *Graph) GetOrCreateNode(label string) int
- func (g *Graph) GetOrCreateNodeWithSubGraph(node string, subGraph string) int
- func (g *Graph) GetOrCreateSubGraph(label string) *Graph
- func (g *Graph) GraphAttribute(name, value string)
- func (g *Graph) HasEdge(n1, n2 *node) bool
- func (g *Graph) HasEdgeContainLabel(fromLabel, toLabel, expectedLabel string) bool
- func (g *Graph) HasEdgeWithLabel(fromLabel, toLabel, expectedLabel string) bool
- func (g *Graph) IsConnected(fromLabel, toLabel string) bool
- func (g *Graph) IsNeighbor(node1, node2 string) bool
- func (g *Graph) IsSubGraph() bool
- func (g *Graph) MakeDirected()
- func (g *Graph) MakeSameRank(node1, node2 int, others ...int)
- func (g *Graph) NodeAttribute(id int, name, value string)
- func (g *Graph) NodeExisted(label string) (int, bool)
- func (g *Graph) Root() *Graph
- func (g *Graph) SetNode(id int, label string)
- func (g *Graph) SetTitle(title string)
Constants ¶
const ( Shape = "shape" Style = "style" Color = "color" FillColor = "fillcolor" FontName = "fontname" FontSize = "fontsize" FontColor = "fontcolor" NodeSep = "nodesep" )
Common attribute names
const ( ShapeBox = "box" ShapePolygon = "polygon" ShapeEllipse = "ellipse" ShapeOval = "oval" ShapeCircle = "circle" ShapePoint = "point" ShapeEgg = "egg" ShapeTriangle = "triangle" ShapeNone = "none" ShapeDiamond = "diamond" ShapeRectangle = "rectangle" ShapeSquare = "square" )
Common values for shape attribute
const ( StyleSolid = "solid" StyleDashed = "dashed" StyleDotted = "dotted" StyleBold = "bold" StyleRounded = "rounded" StyleFilled = "filled" StyleStriped = "striped" )
Common values for style attribute
Variables ¶
This section is empty.
Functions ¶
func CreateNode ¶
func DotGraphToAsciiArt ¶
func GraphPathNext ¶
func GraphPathPrev ¶
func GraphPathPrevWithFilter ¶
func ShowDotGraphToAsciiArt ¶
Types ¶
type Edge ¶
type Edge struct {
Label string
// contains filtered or unexported fields
}
func CreateEdge ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a set of nodes, edges and attributes that can be translated to DOT language.
func (*Graph) AddDashEdge ¶
AddDashEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge. style
func (*Graph) AddDashEdgeWithoutArrowHead ¶
AddDashEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge. style
func (*Graph) AddEdge ¶
AddEdge adds a new edge between the given nodes with the specified label and returns an id for the new edge.
func (*Graph) AddEdgeByLabel ¶
AddEdgeByLabel adds a new edge between the nodes with the given
func (*Graph) AddEdgeInRoot ¶
func (*Graph) AddEdgeWithSubGraph ¶
func (*Graph) CreateSubGraph ¶
func (*Graph) DefaultEdgeAttribute ¶
DefaultEdgeAttribute sets an attribute for all edges by default.
func (*Graph) DefaultNodeAttribute ¶
DefaultNodeAttribute sets an attribute for all nodes by default.
func (*Graph) DrawMultipleEdges ¶
func (g *Graph) DrawMultipleEdges()
DrawMultipleEdges causes multiple edges between same pair of nodes to be drawn separately. By default, for a given pair of nodes, only the edge that was last added to the graph is drawn.
func (*Graph) EdgeAttribute ¶
EdgeAttribute sets an attribute for the specified edge.
func (*Graph) GenerateDOT ¶
func (*Graph) GenerateDOTString ¶
func (*Graph) GetAllEdgeLabels ¶
GetAllEdgeLabels returns all labels of edges between two nodes
func (*Graph) GetAllEdges ¶
GetAllEdges returns all edges in the graph as a slice of edge info
func (*Graph) GetAllNodes ¶
GetAllNodes returns all node labels in the graph
func (*Graph) GetEdgeLabel ¶
GetEdgeLabel returns the label of the edge between two nodes If multiple edges exist, returns the first one found
func (*Graph) GetNodeByID ¶
func (*Graph) GetNodeLabel ¶
GetNodeLabel returns the label of a node by its label name
func (*Graph) GetNodesByLabel ¶
func (*Graph) GetOrCreateNode ¶
GetOrCreateNode returns the id of the node with the given label if it
func (*Graph) GetOrCreateNodeWithSubGraph ¶
func (*Graph) GetOrCreateSubGraph ¶
func (*Graph) GraphAttribute ¶
GraphAttribute sets an attribute for the graph
func (*Graph) HasEdgeContainLabel ¶
func (*Graph) HasEdgeWithLabel ¶
HasEdgeWithLabel checks if there is an edge between two nodes with the specified label
func (*Graph) IsConnected ¶
IsConnected checks if there is a path from node 'from' to node 'to' Uses depth-first search to find connectivity
func (*Graph) IsNeighbor ¶
IsNeighbor checks if two nodes are directly connected (neighbors) Returns true if there is a direct edge between the two nodes, false otherwise
func (*Graph) IsSubGraph ¶
func (*Graph) MakeDirected ¶
func (g *Graph) MakeDirected()
MakeDirected makes the graph a directed graph. By default, a new graph is undirected
func (*Graph) MakeSameRank ¶
MakeSameRank causes the specified nodes to be drawn on the same rank. Only effective when using the dot tool.
func (*Graph) NodeAttribute ¶
NodeAttribute sets an attribute for the specified node.
func (*Graph) NodeExisted ¶
NodeExisted returns the id of the node with the given label if it