-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Core/Peripheral Classification Methods #276
base: dev
Are you sure you want to change the base?
Changes from all commits
65d5c9c
b392d1a
c5d37d4
725792d
480d2e3
07669a7
75125bc
6411087
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
## Copyright 2019 by Christian Hechtl <[email protected]> | ||
## Copyright 2021 by Christian Hechtl <[email protected]> | ||
## Copyright 2023-2024 by Maximilian Löffler <[email protected]> | ||
## Copyright 2024 by Leo Sendelbach <[email protected]> | ||
## All Rights Reserved. | ||
|
||
|
||
|
@@ -105,6 +106,117 @@ test_that("Eigenvector classification", { | |
expect_equal(expected, result, tolerance = 0.0001) | ||
}) | ||
|
||
test_that("Hierarchy classification", { | ||
|
||
vertices = data.frame( | ||
name = c("Olaf", "Thomas", "Karl"), | ||
kind = TYPE.AUTHOR, | ||
type = TYPE.AUTHOR | ||
) | ||
edges = data.frame( | ||
from = c("Olaf", "Thomas", "Karl", "Thomas"), | ||
to = c("Thomas", "Karl", "Olaf", "Thomas"), | ||
func = c("GLOBAL", "test2.c::test2", "GLOBAL", "test2.c::test2"), | ||
hash = c("0a1a5c523d835459c42f33e863623138555e2526", | ||
"418d1dc4929ad1df251d2aeb833dd45757b04a6f", | ||
"5a5ec9675e98187e1e92561e1888aa6f04faa338", | ||
"d01921773fae4bed8186b0aa411d6a2f7a6626e6"), | ||
file = c("GLOBAL", "test2.c", "GLOBAL", "test2.c"), | ||
base.hash = c("3a0ed78458b3976243db6829f63eba3eead26774", | ||
"0a1a5c523d835459c42f33e863623138555e2526", | ||
"1143db502761379c2bfcecc2007fc34282e7ee61", | ||
"0a1a5c523d835459c42f33e863623138555e2526"), | ||
base.func = c("test2.c::test2", "test2.c::test2", | ||
"test3.c::test_function", "test2.c::test2"), | ||
base.file = c("test2.c", "test2.c", "test3.c", "test2.c"), | ||
artifact.type = c("CommitInteraction", "CommitInteraction", "CommitInteraction", "CommitInteraction"), | ||
weight = c(1, 1, 1, 1), | ||
type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA), | ||
relation = c("commit.interaction", "commit.interaction", "commit.interaction", "commit.interaction") | ||
) | ||
test.network = igraph::graph_from_data_frame(edges, directed = FALSE, vertices = vertices) | ||
|
||
## Act | ||
result = get.author.class.network.hierarchy(test.network) | ||
## Assert | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a blank line before the comment? |
||
expected.core = data.frame(author.name = c("Thomas"), | ||
hierarchy = c(4)) | ||
expected.peripheral = data.frame(author.name = c("Olaf", "Karl"), | ||
hierarchy = c(2, 2)) | ||
expected = list(core = expected.core, peripheral = expected.peripheral) | ||
row.names(result[["core"]]) = NULL | ||
row.names(result[["peripheral"]]) = NULL | ||
expect_equal(expected, result) | ||
}) | ||
|
||
test_that("Betweenness classification", { | ||
|
||
## Act | ||
result = get.author.class.network.betweenness(network) | ||
|
||
## Assert | ||
expected.core = data.frame(author.name = c("Olaf"), | ||
betweenness.centrality = c(1)) | ||
expected.peripheral = data.frame(author.name = c("Björn", "udo", "Thomas", "Fritz [email protected]", | ||
"georg", "Hans"), | ||
betweenness.centrality = c(0, 0, 0, 0, 0, 0)) | ||
expected = list(core = expected.core, peripheral = expected.peripheral) | ||
row.names(result[["core"]]) = NULL | ||
row.names(result[["peripheral"]]) = NULL | ||
expect_equal(expected, result) | ||
}) | ||
|
||
test_that("Closeness classification", { | ||
|
||
## Act | ||
result = get.author.class.network.closeness(network) | ||
|
||
## Assert | ||
expected.core = data.frame(author.name = c("Olaf"), | ||
closeness.centrality = c(0.5)) | ||
expected.peripheral = data.frame(author.name = c("Björn", "Thomas", "udo", "Fritz [email protected]", | ||
"georg", "Hans"), | ||
closeness.centrality = c(0.33333, 0.33333, 0.0, 0.0, 0.0, 0.0)) | ||
expected = list(core = expected.core, peripheral = expected.peripheral) | ||
row.names(result[["core"]]) = NULL | ||
row.names(result[["peripheral"]]) = NULL | ||
expect_equal(expected, result, tolerance = 0.0001) | ||
}) | ||
|
||
test_that("Pagerank classification", { | ||
|
||
## Act | ||
result = get.author.class.network.pagerank(network) | ||
|
||
## Assert | ||
expected.core = data.frame(author.name = c("Olaf"), | ||
pagerank.centrality = c(0.40541)) | ||
expected.peripheral = data.frame(author.name = c("Björn", "Thomas", "udo", "Fritz [email protected]", | ||
"georg", "Hans"), | ||
pagerank.centrality = c(0.21396, 0.21396, 0.041667, 0.041667, 0.041667, 0.041667)) | ||
expected = list(core = expected.core, peripheral = expected.peripheral) | ||
row.names(result[["core"]]) = NULL | ||
row.names(result[["peripheral"]]) = NULL | ||
expect_equal(expected, result, tolerance = 0.0001) | ||
}) | ||
|
||
test_that("Eccentricity classification", { | ||
|
||
## Act | ||
result = get.author.class.network.eccentricity(network) | ||
|
||
## Assert | ||
expected.core = data.frame(author.name = c("Olaf"), | ||
eccentricity = c(1)) | ||
expected.peripheral = data.frame(author.name = c("Björn", "udo", "Thomas", "Fritz [email protected]", | ||
"georg", "Hans"), | ||
eccentricity = c(0, 0, 0, 0, 0, 0)) | ||
expected = list(core = expected.core, peripheral = expected.peripheral) | ||
row.names(result[["core"]]) = NULL | ||
row.names(result[["peripheral"]]) = NULL | ||
expect_equal(expected, result) | ||
}) | ||
|
||
# TODO: Add a test for hierarchy classification | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this TODO comment as soon as you have added another test for hierarchy classification. Thanks! |
||
|
||
test_that("Commit-count classification using 'result.limit'" , { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the copyright header and include 2025 😉