File: test_bug-1073705-indexing.R

package info (click to toggle)
r-cran-igraph 1.0.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,232 kB
  • sloc: ansic: 173,538; cpp: 19,365; fortran: 4,550; yacc: 1,164; tcl: 931; lex: 484; makefile: 149; sh: 9
file content (23 lines) | stat: -rw-r--r-- 644 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

context("Bug 1073705")

test_that("Weighted indexing does not remove edges", {
  library(igraph)

  g <- make_ring(10)
  g[1, 2, attr="weight"] <- 0
  expect_that("weight" %in% edge_attr_names(g), is_true())
  expect_that(E(g)$weight, equals(c(0, rep(NA, 9))))

  el <- as_edgelist(g)
  g[from=el[,1], to=el[,2], attr="sim"] <- rep(0:1, length=ecount(g))
  expect_that("sim" %in% edge_attr_names(g), is_true())
  expect_that(E(g)$sim, equals(rep(0:1, 5)))

  V(g)$name <- letters[seq_len(vcount(g))]
  el <- as_edgelist(g)
  g[from=el[,1], to=el[,2], attr="sim"] <- rep(1:0, length=ecount(g))
  expect_that(E(g)$sim, equals(rep(1:0, 5)))
})