Skip to content
Open
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
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: network
Version: 1.20.0-784
Date: 2026-03-02
Version: 1.20.0-790
Date: 2026-10-09
Title: Classes for Relational Data
Authors@R: c(
person("Carter T.", "Butts", role=c("aut","cre"), email="buttsc@uci.edu"),
Expand Down
67 changes: 50 additions & 17 deletions R/operators.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,26 +322,59 @@
val<-value[cbind(match(el[,1],sort(unique(el[,1]))), match(el[,2],sort(unique(el[,2]))))]
else
val<-rep(as.vector(value),length.out=NROW(el))

#Filter out redundant edges if undirected
if (!is.directed(x)) {
el <- cbind(pmin(el[,1], el[,2]), pmax(el[,1], el[,2]))

Check warning on line 328 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=328,col=56,[commas_linter] Put a space after a comma.

Check warning on line 328 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=328,col=48,[commas_linter] Put a space after a comma.

Check warning on line 328 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=328,col=34,[commas_linter] Put a space after a comma.

Check warning on line 328 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=328,col=26,[commas_linter] Put a space after a comma.
#Nonzero, nonFALSE values trump NA; NA trumps 0.
o <- order((!is.na(val) & (val == 0 | val == FALSE)) * 2L + is.na(val) * 1L, na.last = FALSE)

Check warning on line 330 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=330,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 97 characters.
el <- el[o, , drop = FALSE]
val <- val[o]
u <- !duplicated(el)
if (!all(u)) {
el <- el[u, , drop = FALSE]
val <- val[u]
}
}

#Filter out self-loops if disabled
if (!has.loops(x) && !all(nonloops <- el[,1] != el[,2])) {

Check warning on line 341 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=341,col=55,[commas_linter] Put a space after a comma.

Check warning on line 341 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=341,col=45,[commas_linter] Put a space after a comma.
el <- el[nonloops, , drop = FALSE]
val <- val[nonloops]
}

#Perform the changes
if(is.null(names.eval)){ #If no names given, don't store values
for (k in seq_along(val)) {
eid <- get.edgeIDs(x,el[k,1],el[k,2],neighborhood="out", na.omit=FALSE)
if (!is.na(val[k]) & val[k] == 0) {
# delete edge
if (length(eid) > 0) x<-delete.edges(x,eid)
} else {
if (length(eid) == 0 & (has.loops(x)|(el[k,1]!=el[k,2]))) {
# add edge if needed
x<-add.edges(x,as.list(el[k,1]),as.list(el[k,2]))
eid <- get.edgeIDs(x,el[k,1],el[k,2],neighborhood="out", na.omit=FALSE)
}
if (is.na(val[k])) {
set.edge.attribute(x,"na",TRUE,eid) # set to NA
} else if (val[k] == 1) {
set.edge.attribute(x,"na",FALSE,eid) # set to 1
}
}

el0 <- as.matrix(x, matrix.type = "edgelist", na.rm = FALSE)
if (!is.directed(x)) el0 <- cbind(pmin(el0[,1], el0[,2]), pmax(el0[,1], el0[,2]))

Check warning on line 350 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=350,col=82,[commas_linter] Put a space after a comma.

Check warning on line 350 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=350,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 85 characters.

Check warning on line 350 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=350,col=73,[commas_linter] Put a space after a comma.

Check warning on line 350 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=350,col=58,[commas_linter] Put a space after a comma.

Check warning on line 350 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=350,col=49,[commas_linter] Put a space after a comma.

# Rowwise intersection of el and el0
inter <- duplicated(rbind(el0, el))[rep(c(FALSE, TRUE), c(nrow(el0), nrow(el)))]

Check warning on line 353 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=353,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 84 characters.

if (any(inter)) {
todel <- which(inter & !is.na(val) & !val)
to1 <- which(inter & !is.na(val) & val)
toNA <- which(inter & is.na(val))

Check warning on line 358 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=358,col=7,[object_name_linter] Variable and function name style should match snake_case or symbols.

# unlist() is needed in case of multiplex edges.
el_eids <- function(rows) unlist(lapply(rows, function(k) get.edgeIDs(x, el[k,1], el[k,2], neighborhood = "out", na.omit=FALSE)))

Check warning on line 361 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=361,col=127,[infix_spaces_linter] Put spaces around all infix operators.

Check warning on line 361 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=361,col=94,[commas_linter] Put a space after a comma.

Check warning on line 361 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=361,col=85,[commas_linter] Put a space after a comma.

Check warning on line 361 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=361,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 135 characters.

if(length(todel)) delete.edges(x, eid = el_eids(todel))

Check warning on line 363 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=363,col=9,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
if(length(toNA)) set.edge.attribute(x, "na", TRUE, el_eids(toNA))

Check warning on line 364 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=364,col=9,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
if(length(to1)) set.edge.attribute(x, "na", FALSE, el_eids(to1))

Check warning on line 365 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=365,col=9,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
}

if (any(!inter)) {
toinsNA <- which(!inter & is.na(val))

Check warning on line 369 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=369,col=7,[object_name_linter] Variable and function name style should match snake_case or symbols.
toins1 <- which(!inter & !is.na(val) & val)

if (length(toinsNA)) add.edges(x, as.list(el[toinsNA,1]), as.list(el[toinsNA,2]),

Check warning on line 372 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=372,col=84,[commas_linter] Put a space after a comma.

Check warning on line 372 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=372,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 87 characters.

Check warning on line 372 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=372,col=60,[commas_linter] Put a space after a comma.
names.eval = "na", vals.eval = TRUE)
if (length(toins1)) add.edges(x, as.list(el[toins1,1]), as.list(el[toins1,2]),

Check warning on line 374 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=374,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 84 characters.

Check warning on line 374 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=374,col=81,[commas_linter] Put a space after a comma.

Check warning on line 374 in R/operators.R

View workflow job for this annotation

GitHub Actions / lint-changed-warnings

file=R/operators.R,line=374,col=58,[commas_linter] Put a space after a comma.
names.eval = "na", vals.eval = FALSE)
}

}else{ #An attribute name was given, so store values
epresent<-vector()
eid<-vector()
Expand Down
Loading