From af80551d0615a49b86e45ff596bd75941ee88f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20L=C3=B6ffler?= Date: Wed, 3 Jul 2024 19:20:20 +0200 Subject: [PATCH] Test simplification of networks with graph attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Löffler --- tests/test-networks.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test-networks.R b/tests/test-networks.R index bda78eb0..e77cecef 100644 --- a/tests/test-networks.R +++ b/tests/test-networks.R @@ -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") + @@ -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) @@ -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", {