1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
package dot
// Edge represents a graph edge between two Nodes.
type Edge struct {
AttributesMap
graph *Graph
from, to Node
fromPort, toPort string
}
// Attr sets key=value and returns the Edge.
func (e Edge) Attr(key string, value interface{}) Edge {
e.AttributesMap.Attr(key, value)
return e
}
// Label sets "label"=value and returns the Edge.
// Same as Attr("label",value)
func (e Edge) Label(value interface{}) Edge {
e.AttributesMap.Attr("label", value)
return e
}
// Solid sets the edge attribute "style" to "solid"
// Default style
func (e Edge) Solid() Edge {
return e.Attr("style", "solid")
}
// Bold sets the edge attribute "style" to "bold"
func (e Edge) Bold() Edge {
return e.Attr("style", "bold")
}
// Dashed sets the edge attribute "style" to "dashed"
func (e Edge) Dashed() Edge {
return e.Attr("style", "dashed")
}
// Dotted sets the edge attribute "style" to "dotted"
func (e Edge) Dotted() Edge {
return e.Attr("style", "dotted")
}
// Edge returns a new Edge between the "to" node of this Edge and the argument Node.
func (e Edge) Edge(to Node, labels ...string) Edge {
return e.graph.Edge(e.to, to, labels...)
}
// ReverseEdge returns a new Edge between the "from" node of this Edge and the argument Node.
func (e Edge) ReverseEdge(from Node, labels ...string) Edge {
return e.graph.Edge(from, e.to, labels...)
}
// EdgesTo returns all existing edges between the "to" Node of the Edge and the argument Node.
func (e Edge) EdgesTo(to Node) []Edge {
return e.graph.FindEdges(e.to, to)
}
// GetAttr returns the value stored by a name. Returns nil if missing.
func (e Edge) GetAttr(name string) interface{} {
return e.attributes[name]
}
// From returns the Node that this edge is pointing from.
func (e Edge) From() Node {
return e.from
}
// To returns the Node that this edge is pointing to.
func (e Edge) To() Node {
return e.to
}
|