Skip to content

Commit

Permalink
Test simplification of networks with graph attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Löffler <s8maloef@stud.uni-saarland.de>
  • Loading branch information
MaLoefUDS committed Jul 3, 2024
1 parent ff30f32 commit af80551
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test-networks.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ test_that("Simplify multiple basic multi-relational networks", {
network.B = igraph::add_edges(network.B, c("C", "D"), type = TYPE.EDGES.INTRA, relation = "cochange")
}

## add graph attributes
network.A = igraph::set_graph_attr(network.A, "name", "network.A")
network.B = igraph::set_graph_attr(network.B, "name", "network.B")
networks = list(A = network.A, B = network.B)

network.A.expected = igraph::make_empty_graph(n = 0, directed = FALSE) +
igraph::vertices("A", "B", type = TYPE.ARTIFACT, kind = "feature") +
igraph::edges("A", "B", type = TYPE.EDGES.INTRA, relation = "mail") +
Expand All @@ -251,7 +256,6 @@ test_that("Simplify multiple basic multi-relational networks", {
igraph::vertices("C", "D", type = TYPE.AUTHOR, kind = TYPE.AUTHOR) +
igraph::edges("C", "D", type = TYPE.EDGES.INTRA, relation = "mail") +
igraph::edges("C", "D", type = TYPE.EDGES.INTRA, relation = "cochange")
networks = list(A = network.A, B = network.B)

## simplify networks without simplifying multiple relations into single edges
networks.simplified = simplify.networks(networks, simplify.multiple.relations = FALSE)
Expand All @@ -269,6 +273,10 @@ test_that("Simplify multiple basic multi-relational networks", {
expect_identical(igraph::E(networks.simplified[[i]])$type[[1]], "Unipartite")
expect_identical(igraph::E(networks.simplified[[i]])$relation[[1]], c("cochange", "mail"))
}

## verify graph attributes
expect_identical(igraph::graph_attr(networks.simplified[["A"]], "name"), "network.A")
expect_identical(igraph::graph_attr(networks.simplified[["B"]], "name"), "network.B")
})

test_that("Remove isolated vertices", {
Expand Down

0 comments on commit af80551

Please sign in to comment.