-
-
Notifications
You must be signed in to change notification settings - Fork 206
chore: autogenerate igraph_incident()
#2100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
14d58de
dd11743
f790e9b
5653e13
8c1d6b9
5396b2c
940b223
56599ac
04a4981
3a051d0
df89cc7
c14363e
20bb1c9
3a5231f
aaccdcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,16 +388,15 @@ incident <- function(graph, v, mode = c("all", "out", "in", "total")) { | |
ensure_igraph(graph) | ||
if (is_directed(graph)) { | ||
mode <- igraph.match.arg(mode) | ||
mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3) | ||
} else { | ||
mode <- 1 | ||
mode <- "out" | ||
} | ||
v <- as_igraph_vs(graph, v) | ||
if (length(v) == 0) { | ||
stop("No vertex was specified") | ||
} | ||
on.exit(.Call(R_igraph_finalizer)) | ||
res <- .Call(R_igraph_incident, graph, v - 1, as.numeric(mode)) + 1L | ||
|
||
res <- incident_impl(graph, vid = v, mode = mode) | ||
|
||
if (igraph_opt("return.vs.es")) { | ||
res <- create_es(graph, res) | ||
|
@@ -687,20 +686,16 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { | |
incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { | ||
ensure_igraph(graph) | ||
|
||
vv <- as_igraph_vs(graph, v) - 1 | ||
mode <- switch(match.arg(mode), "out" = 1, "in" = 2, "all" = 3, "total" = 3) | ||
vv <- as_igraph_vs(graph, v) | ||
|
||
on.exit(.Call(R_igraph_finalizer)) | ||
|
||
res <- .Call(R_igraph_incident_edges, graph, vv, mode) | ||
res <- lapply(res, `+`, 1) | ||
res <- incident_impl(graph, vid = vv, mode = mode) | ||
|
||
if (igraph_opt("return.vs.es")) { | ||
res <- lapply(res, unsafe_create_es, graph = graph, es = E(graph)) | ||
} | ||
|
||
if (is_named(graph)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to move this into the yaml thus into aaa-auto.R There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @szhorvat I tried my best by looking at the YAML of functions with these lines: if (igraph_opt("add.vertex.names") && is_named(graph)) {
names(res) <- vertex_attr(graph, "name", vids)
} but didn't manage to get it right. |
||
names(res) <- V(graph)$name[vv + 1] | ||
names(res) <- V(graph)$name[vv] | ||
} | ||
|
||
res | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3894,27 +3894,6 @@ SEXP R_igraph_neighbors(SEXP graph, SEXP pvid, SEXP pmode) { | |
return result; | ||
} | ||
|
||
SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is with this partial removal, not below. |
||
|
||
igraph_t g; | ||
igraph_vector_int_t neis; | ||
SEXP result; | ||
igraph_real_t vid; | ||
igraph_neimode_t mode; | ||
|
||
igraph_vector_int_init(&neis, 0); | ||
vid=REAL(pvid)[0]; | ||
mode = (igraph_neimode_t) Rf_asInteger(pmode); | ||
R_SEXP_to_igraph(graph, &g); | ||
IGRAPH_R_CHECK(igraph_incident(&g, &neis, (igraph_integer_t) vid, mode)); | ||
|
||
PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); | ||
igraph_vector_int_destroy(&neis); | ||
|
||
UNPROTECT(1); | ||
return result; | ||
} | ||
|
||
SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { | ||
|
||
igraph_es_t es; | ||
|
@@ -8708,4 +8687,4 @@ SEXP R_igraph_add_env(SEXP graph) { | |
|
||
SEXP R_igraph_get_graph_id(SEXP graph) { | ||
return Rf_findVar(Rf_install("myid"), R_igraph_graph_env(graph)); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.