Edges can be created from scratch
var a1 = new DotNode("a1")
var b1 = new DotNode("b1")
var edge = new DotEdge(a1, b1)
edge["color"] = "blue"
Then added to a graph
var graph = new DotGraph("G", "digraph")
graph.add edge
Or can be created directly from an existing graph
var a2 = graph.add_node("a2")
var b2 = graph.add_node("b2")
var edge2 = graph.add_edge(a2, b2)
edge2["color"] = "red"
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
dot :: DotEdge :: defaultinit
core :: Object :: defaultinit
dot :: DotElement :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# A dot edge that links two nodes
#
# Edges can be created from scratch
# ~~~
# var a1 = new DotNode("a1")
# var b1 = new DotNode("b1")
# var edge = new DotEdge(a1, b1)
# edge["color"] = "blue"
# ~~~
# Then added to a graph
# ~~~
# var graph = new DotGraph("G", "digraph")
# graph.add edge
# ~~~
# Or can be created directly from an existing graph
# ~~~
# var a2 = graph.add_node("a2")
# var b2 = graph.add_node("b2")
# var edge2 = graph.add_edge(a2, b2)
# edge2["color"] = "red"
# ~~~
class DotEdge
super DotElement
autoinit from, to
# Node this edge is from
var from: DotElement
# Node this edge goes to
var to: DotElement
# Is this edge directed?
var directed = true is writable
redef fun id do return "{from.id}--{to.id}"
redef fun to_dot do
var res = new Buffer
res.append "\"{from.escape_id}\" "
if directed then
res.append "->"
else
res.append "--"
end
res.append " \"{to.escape_id}\" "
if attrs.not_empty then res.append "[{attrs.to_dot(",")}]"
return res.write_to_string
end
end
lib/dot/dot.nit:194,1--242,3