Skip to content

Commit

Permalink
Add test for 'remove.duplicate.edges'
Browse files Browse the repository at this point in the history
Works towards se-sic#138.

Signed-off-by: Maximilian Löffler <[email protected]>
  • Loading branch information
MaLoefUDS committed Sep 10, 2024
1 parent dcd1ff7 commit 8c308cc
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test-networks.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,47 @@ test_that("Remove isolated authors given a specific edge type", {

})

test_that("Remove duplicate edges", {

## configurations
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT)
net.conf = NetworkConf$new()
net.conf$update.values(list("author.respect.temporal.order" = TRUE, author.directed = FALSE))
proj.data = ProjectData$new(project.conf = proj.conf)
network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf)
network.builder$update.network.conf(updated.values = list(author.relation = "mail"))

## construct data for expected network
edges = data.frame(comb.1. = c("Björn", "Olaf", rep("Hans", 5)),
comb.2. = c("Olaf", "Thomas", rep("Hans", 5)),
date = get.date.from.string(c("2016-07-12 15:58:50", "2016-07-12 16:05:37",
"2010-07-12 12:05:41", "2010-07-12 12:05:42",
"2010-07-12 12:05:43", "2010-07-12 12:05:44",
"2010-07-12 12:05:45")),
artifact.type = rep("Mail", 7),
message.id = c("<[email protected]>",
"<[email protected]>",
"<[email protected]>", "<[email protected]>",
"<[email protected]>", "<[email protected]>",
"<[email protected]>"),
thread = c("<thread-13#8>", "<thread-13#9>", rep("<thread-42#6>", 5)),
weight = rep(1, 7),
type = rep(TYPE.EDGES.INTRA, 7),
relation = rep("mail", 7))
vertices = data.frame(name = c("Björn", "udo", "Olaf", "Thomas", "Fritz [email protected]", "georg", "Hans"),
kind = rep("Author", 7),
type = rep("Author", 7))

## build expected network
network.expected = igraph::graph_from_data_frame(edges, directed = FALSE, vertices = vertices)

## build network with unique edges
network = network.builder$get.author.network()
network.built = remove.duplicate.edges(network)

assert.networks.equal(network.expected, network.built)
})


## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
## Merge -------------------------------------------------------------------
Expand Down

0 comments on commit 8c308cc

Please sign in to comment.