Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 39 additions & 117 deletions R/aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,9 @@ get_all_eids_between_impl <- function(graph, from, to, directed=TRUE) {
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
directed <- as.logical(directed)

on.exit( .Call(R_igraph_finalizer) )
Expand Down Expand Up @@ -813,13 +809,9 @@ are_adjacent_impl <- function(graph, v1, v2) {
# Argument checks
ensure_igraph(graph)
v1 <- as_igraph_vs(graph, v1)
if (length(v1) == 0) {
stop("No vertex was specified")
}
check_vertex(v1)
v2 <- as_igraph_vs(graph, v2)
if (length(v2) == 0) {
stop("No vertex was specified")
}
check_vertex(v2)

on.exit( .Call(R_igraph_finalizer) )
# Function call
Expand Down Expand Up @@ -881,13 +873,9 @@ get_shortest_path_impl <- function(graph, from, to, mode=c("out", "in", "all", "
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

on.exit( .Call(R_igraph_finalizer) )
Expand All @@ -906,13 +894,9 @@ get_shortest_path_bellman_ford_impl <- function(graph, from, to, weights=NULL, m
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
Expand All @@ -939,13 +923,9 @@ get_shortest_path_dijkstra_impl <- function(graph, from, to, weights=NULL, mode=
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
Expand All @@ -972,9 +952,7 @@ get_all_shortest_paths_impl <- function(graph, from, to, mode=c("out", "in", "al
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

Expand All @@ -994,9 +972,7 @@ get_all_shortest_paths_dijkstra_impl <- function(graph, from, to=V(graph), weigh
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
Expand Down Expand Up @@ -1047,9 +1023,7 @@ get_all_simple_paths_impl <- function(graph, from, to=V(graph), cutoff=-1, mode=
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
cutoff <- as.numeric(cutoff)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)
Expand Down Expand Up @@ -1077,13 +1051,9 @@ get_k_shortest_paths_impl <- function(graph, from, to, ..., k, weights=NULL, mod
}
k <- as.numeric(k)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

on.exit( .Call(R_igraph_finalizer) )
Expand All @@ -1102,13 +1072,9 @@ get_widest_path_impl <- function(graph, from, to, weights=NULL, mode=c("out", "i
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (length(to) == 0) {
stop("No vertex was specified")
}
check_vertex(to)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
}
Expand All @@ -1135,9 +1101,7 @@ get_widest_paths_impl <- function(graph, from, to=V(graph), weights=NULL, mode=c
# Argument checks
ensure_igraph(graph)
from <- as_igraph_vs(graph, from)
if (length(from) == 0) {
stop("No vertex was specified")
}
check_vertex(from)
to <- as_igraph_vs(graph, to)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
Expand Down Expand Up @@ -2319,9 +2283,7 @@ pseudo_diameter_impl <- function(graph, start.vid, directed=TRUE, unconnected=TR
# Argument checks
ensure_igraph(graph)
start.vid <- as_igraph_vs(graph, start.vid)
if (length(start.vid) == 0) {
stop("No vertex was specified")
}
check_vertex(start.vid)
directed <- as.logical(directed)
unconnected <- as.logical(unconnected)

Expand All @@ -2344,9 +2306,7 @@ pseudo_diameter_dijkstra_impl <- function(graph, weights=NULL, start.vid, direct
weights <- NULL
}
start.vid <- as_igraph_vs(graph, start.vid)
if (length(start.vid) == 0) {
stop("No vertex was specified")
}
check_vertex(start.vid)
directed <- as.logical(directed)
unconnected <- as.logical(unconnected)

Expand Down Expand Up @@ -2391,9 +2351,7 @@ random_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "i
weights <- NULL
}
start <- as_igraph_vs(graph, start)
if (length(start) == 0) {
stop("No vertex was specified")
}
check_vertex(start)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)
steps <- as.numeric(steps)
stuck <- switch(igraph.match.arg(stuck), "error" = 0L, "return" = 1L)
Expand Down Expand Up @@ -2526,9 +2484,7 @@ bfs_simple_impl <- function(graph, root, mode=c("out", "in", "all", "total")) {
# Argument checks
ensure_igraph(graph)
root <- as_igraph_vs(graph, root)
if (length(root) == 0) {
stop("No vertex was specified")
}
check_vertex(root)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

on.exit( .Call(R_igraph_finalizer) )
Expand Down Expand Up @@ -2978,9 +2934,7 @@ layout_star_impl <- function(graph, center=V(graph)[1], order=NULL) {
# Argument checks
ensure_igraph(graph)
center <- as_igraph_vs(graph, center)
if (length(center) == 0) {
stop("No vertex was specified")
}
check_vertex(center)
if (!is.null(order)) order <- as.numeric(order)-1

on.exit( .Call(R_igraph_finalizer) )
Expand Down Expand Up @@ -4078,9 +4032,7 @@ rooted_product_impl <- function(g1, g2, root) {
ensure_igraph(g1)
ensure_igraph(g2)
root <- as_igraph_vs(g2, root)
if (length(root) == 0) {
stop("No vertex was specified")
}
check_vertex(root)

on.exit( .Call(R_igraph_finalizer) )
# Function call
Expand Down Expand Up @@ -4112,13 +4064,9 @@ maxflow_impl <- function(graph, source, target, capacity=NULL) {
# Argument checks
ensure_igraph(graph)
source <- as_igraph_vs(graph, source)
if (length(source) == 0) {
stop("No vertex was specified")
}
check_vertex(source)
target <- as_igraph_vs(graph, target)
if (length(target) == 0) {
stop("No vertex was specified")
}
check_vertex(target)
if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) {
capacity <- E(graph)$capacity
}
Expand Down Expand Up @@ -4187,13 +4135,9 @@ st_mincut_impl <- function(graph, source, target, capacity=NULL) {
# Argument checks
ensure_igraph(graph)
source <- as_igraph_vs(graph, source)
if (length(source) == 0) {
stop("No vertex was specified")
}
check_vertex(source)
target <- as_igraph_vs(graph, target)
if (length(target) == 0) {
stop("No vertex was specified")
}
check_vertex(target)
if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) {
capacity <- E(graph)$capacity
}
Expand Down Expand Up @@ -4222,9 +4166,7 @@ dominator_tree_impl <- function(graph, root, mode=c("out", "in", "all", "total")
# Argument checks
ensure_igraph(graph)
root <- as_igraph_vs(graph, root)
if (length(root) == 0) {
stop("No vertex was specified")
}
check_vertex(root)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

on.exit( .Call(R_igraph_finalizer) )
Expand All @@ -4240,13 +4182,9 @@ all_st_cuts_impl <- function(graph, source, target) {
# Argument checks
ensure_igraph(graph)
source <- as_igraph_vs(graph, source)
if (length(source) == 0) {
stop("No vertex was specified")
}
check_vertex(source)
target <- as_igraph_vs(graph, target)
if (length(target) == 0) {
stop("No vertex was specified")
}
check_vertex(target)

on.exit( .Call(R_igraph_finalizer) )
# Function call
Expand All @@ -4264,13 +4202,9 @@ all_st_mincuts_impl <- function(graph, source, target, capacity=NULL) {
# Argument checks
ensure_igraph(graph)
source <- as_igraph_vs(graph, source)
if (length(source) == 0) {
stop("No vertex was specified")
}
check_vertex(source)
target <- as_igraph_vs(graph, target)
if (length(target) == 0) {
stop("No vertex was specified")
}
check_vertex(target)
if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) {
capacity <- E(graph)$capacity
}
Expand Down Expand Up @@ -5176,9 +5110,7 @@ fundamental_cycles_impl <- function(graph, start=NULL, bfs.cutoff=-1, weights=NU
# Argument checks
ensure_igraph(graph)
if (!is.null(start)) start <- as_igraph_vs(graph, start)
if (length(start) == 0) {
stop("No vertex was specified")
}
check_vertex(start)
bfs.cutoff <- as.numeric(bfs.cutoff)
if (is.null(weights) && "weight" %in% edge_attr_names(graph)) {
weights <- E(graph)$weight
Expand Down Expand Up @@ -5310,9 +5242,7 @@ random_spanning_tree_impl <- function(graph, vid=0) {
# Argument checks
ensure_igraph(graph)
if (!is.null(vid)) vid <- as_igraph_vs(graph, vid)
if (length(vid) == 0) {
stop("No vertex was specified")
}
check_vertex(vid)

on.exit( .Call(R_igraph_finalizer) )
# Function call
Expand Down Expand Up @@ -5409,9 +5339,7 @@ deterministic_optimal_imitation_impl <- function(graph, vid, optimality=c("maxim
# Argument checks
ensure_igraph(graph)
vid <- as_igraph_vs(graph, vid)
if (length(vid) == 0) {
stop("No vertex was specified")
}
check_vertex(vid)
optimality <- switch(igraph.match.arg(optimality), "minimum"=0L, "maximum"=1L)
strategies <- as.numeric(strategies)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)
Expand Down Expand Up @@ -5450,9 +5378,7 @@ roulette_wheel_imitation_impl <- function(graph, vid, is.local, quantities, stra
# Argument checks
ensure_igraph(graph)
vid <- as_igraph_vs(graph, vid)
if (length(vid) == 0) {
stop("No vertex was specified")
}
check_vertex(vid)
is.local <- as.logical(is.local)
strategies <- as.numeric(strategies)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)
Expand All @@ -5468,9 +5394,7 @@ stochastic_imitation_impl <- function(graph, vid, algo, quantities, strategies,
# Argument checks
ensure_igraph(graph)
vid <- as_igraph_vs(graph, vid)
if (length(vid) == 0) {
stop("No vertex was specified")
}
check_vertex(vid)
strategies <- as.numeric(strategies)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

Expand All @@ -5496,9 +5420,7 @@ vertex_path_from_edge_path_impl <- function(graph, start=NULL, edge.path, mode=c
# Argument checks
ensure_igraph(graph)
if (!is.null(start)) start <- as_igraph_vs(graph, start)
if (length(start) == 0) {
stop("No vertex was specified")
}
check_vertex(start)
edge.path <- as_igraph_es(graph, edge.path)
mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L)

Expand Down
8 changes: 2 additions & 6 deletions R/interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,7 @@ neighbors <- function(graph, v, mode = c("out", "in", "all", "total")) {
mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3)
}
v <- as_igraph_vs(graph, v)
if (length(v) == 0) {
stop("No vertex was specified")
}
check_vertex(v)
on.exit(.Call(R_igraph_finalizer))
res <- .Call(R_igraph_neighbors, graph, v - 1, as.numeric(mode)) + 1L

Expand Down Expand Up @@ -393,9 +391,7 @@ incident <- function(graph, v, mode = c("all", "out", "in", "total")) {
mode <- 1
}
v <- as_igraph_vs(graph, v)
if (length(v) == 0) {
stop("No vertex was specified")
}
check_vertex(v)
on.exit(.Call(R_igraph_finalizer))
res <- .Call(R_igraph_incident, graph, v - 1, as.numeric(mode)) + 1L

Expand Down
Loading
Loading