(u,v)
to this graph.If there is already an arc from u
to v
in this graph, then
nothing happens. If vertex u
or vertex v
do not exist in the
graph, they are added.
var g = new HashDigraph[Int]
g.add_arc(0, 1)
g.add_arc(1, 2)
assert g.has_arc(0, 1)
assert g.has_arc(1, 2)
assert not g.has_arc(1, 0)
g.add_arc(1, 2)
assert g.num_arcs == 2
# Adds the arc `(u,v)` to this graph.
#
# If there is already an arc from `u` to `v` in this graph, then
# nothing happens. If vertex `u` or vertex `v` do not exist in the
# graph, they are added.
#
# ~~~
# var g = new HashDigraph[Int]
# g.add_arc(0, 1)
# g.add_arc(1, 2)
# assert g.has_arc(0, 1)
# assert g.has_arc(1, 2)
# assert not g.has_arc(1, 0)
# g.add_arc(1, 2)
# assert g.num_arcs == 2
# ~~~
fun add_arc(u, v: V) is abstract
lib/graph/digraph.nit:748,2--764,33
redef fun add_arc(u, v)
do
if not has_vertex(u) then add_vertex(u)
if not has_vertex(v) then add_vertex(v)
if not has_arc(u, v) then
incoming_vertices_map[v].add(u)
outgoing_vertices_map[u].add(v)
invalidated_all_cache
number_of_arcs += 1
end
end
lib/graph/digraph.nit:977,2--987,4
# Adds the arc (u,v) to this graph.
# if `u` is the same as `v` do nothing
#
# ~~~
# var g = new ReflexiveHashDigraph[Int]
# g.add_arc(1, 2)
# g.add_arc(3, 1)
# assert g.has_arc(2,2)
# assert g.has_arc(1,2)
# assert g.has_arc(3,1)
# ~~~
redef fun add_arc(u, v)
do
# Check `u` is the same as `v`
if u != v then
super
end
end
lib/graph/digraph.nit:1030,2--1047,4