This adds a vertex to the graph and reports the id of the newly added vertex.

add_vertex(g)

Arguments

g

A nctx graph

Value

ID of the newly added vertex

Examples

library(RUnit) library(nctx) g <- create_graph(directed=TRUE) checkTrue(nctx::is_directed(g))
#> [1] TRUE
#> [1] TRUE
#> [1] TRUE
v_s <- c(add_vertex(g)) checkEquals(num_vertices(g), 1)
#> [1] TRUE
v_s <- c(v_s, sapply(1:9,function(x){add_vertex(g)})) checkEquals(v_s, c(1:10))
#> [1] TRUE
#> [1] TRUE
add_edge(g, 1, 2)
#> [1] TRUE
#> [1] TRUE
add_edge(g, 2, 3)
#> [1] TRUE
add_edge(g, 3, 4)
#> [1] TRUE
add_edge(g, 4, 5)
#> [1] TRUE
add_edge(g, 3, 5)
#> [1] TRUE
add_edge(g, 5, 9)
#> [1] TRUE
add_edge(g, 6, 4)
#> [1] TRUE
add_edge(g, 7, 4)
#> [1] TRUE
add_edge(g, 2, 6)
#> [1] TRUE
add_edge(g, 8, 2)
#> [1] TRUE
add_edge(g, 9, 4)
#> [1] TRUE
add_edge(g, 3, 10)
#> [1] TRUE
add_edge(g, 10, 5)
#> [1] TRUE
add_edge(g, 10, 9)
#> [1] TRUE
#> [1] TRUE