-
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
Open
Leo-Send
wants to merge
8
commits into
se-sic:dev
Choose a base branch
from
Leo-Send:pullrequest
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
65d5c9c
Add base implementation
Leo-Send b392d1a
Add tests for new classification methods
Leo-Send c5d37d4
Add documentation to new classification methods
Leo-Send 725792d
Update NEWS.md
Leo-Send 480d2e3
Add core/peripheral classification to README
Leo-Send 07669a7
Implement feedback on PR
Leo-Send 75125bc
Add test for hierarchy classification
Leo-Send 6411087
Change formulation in 'README.md'
Leo-Send File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
## Copyright 2019 by Thomas Bock <[email protected]> | ||
## Copyright 2019 by Jakob Kronawitter <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## Copyright 2024 by Leo Sendelbach <[email protected]> | ||
## All Rights Reserved. | ||
## | ||
## This file is derived from following Codeface script: | ||
|
@@ -59,6 +60,10 @@ CLASSIFICATION.TYPE.TO.CATEGORY = list( | |
"network.degree" = "network", | ||
"network.eigen" = "network", | ||
"network.hierarchy" = "network", | ||
"network.betweenness" = "network", | ||
"network.closeness" = "network", | ||
"network.pagerank" = "network", | ||
"network.eccentricity" = "network", | ||
"commit.count" = "count", | ||
"loc.count" = "count", | ||
"mail.count" = "count", | ||
|
@@ -96,7 +101,7 @@ CLASSIFICATION.TYPE.TO.CATEGORY = list( | |
#' Network-based options/metrics (parameter \code{network} has to be specified): | ||
#' - "network.degree" | ||
#' - "network.eigen" | ||
#' - "network.hierarchy" | ||
#' - "network.hierarchy" ###TODO check all documentation | ||
Leo-Send marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#' Count-based options/metrics (parameter \code{proj.data} has to be specified): | ||
#' - "commit.count" | ||
#' - "loc.count" | ||
|
@@ -126,7 +131,8 @@ CLASSIFICATION.TYPE.TO.CATEGORY = list( | |
#' first column and their centrality values in the second column. | ||
get.author.class.by.type = function(network = NULL, | ||
proj.data = NULL, | ||
type = c("network.degree", "network.eigen", "network.hierarchy", | ||
type = c("network.degree", "network.eigen", "network.hierarchy", "network.betweenness", | ||
"network.closeness", "network.pagerank", "network.eccentricity", | ||
"commit.count", "loc.count", "mail.count", "mail.thread.count", | ||
"issue.count", "issue.comment.count", "issue.commented.in.count", | ||
"issue.created.count"), | ||
|
@@ -144,6 +150,10 @@ get.author.class.by.type = function(network = NULL, | |
"network.degree" = "vertex.degree", | ||
"network.eigen" = "eigen.centrality", | ||
"network.hierarchy" = "hierarchy", | ||
"network.betweenness" = "betweenness.centrality", | ||
"network.closeness" = "closeness.centrality", | ||
"network.pagerank" = "pagerank.centrality", | ||
"network.eccentricity" = "eccentricity", | ||
"commit.count" = "commit.count", | ||
"loc.count" = "loc.count", | ||
"mail.count" = "mail.count", | ||
|
@@ -231,6 +241,30 @@ get.author.class.by.type = function(network = NULL, | |
## Construct centrality dataframe | ||
centrality.dataframe = data.frame(author.name = row.names(hierarchy.base.df), | ||
centrality = hierarchy.calculated) | ||
} else if (type == "network.betweenness") { | ||
betweenness.centrality.vec = igraph::betweenness(network, directed = TRUE) | ||
## Construct centrality dataframe | ||
centrality.dataframe = data.frame(author.name = names(betweenness.centrality.vec), | ||
centrality = as.vector(betweenness.centrality.vec)) | ||
} else if (type == "network.closeness") { | ||
closeness.centrality.vec = igraph::closeness(network) | ||
## Construct centrality dataframe | ||
centrality.dataframe = data.frame(author.name = names(closeness.centrality.vec), | ||
centrality = as.vector(closeness.centrality.vec)) | ||
Leo-Send marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else if (type == "network.pagerank") { | ||
pagerank.centrality.vec = igraph::page_rank(network, directed = TRUE)[["vector"]] | ||
## Construct centrality dataframe | ||
centrality.dataframe = data.frame(author.name = names(pagerank.centrality.vec), | ||
centrality = as.vector(pagerank.centrality.vec)) | ||
} else if (type == "network.eccentricity") { | ||
eccentricity.vec = igraph::eccentricity(network) | ||
## since core developers are expected to have a lower eccentricity, | ||
## we need to invert all non-zero values | ||
indices = which(eccentricity.vec > 0) | ||
Leo-Send marked this conversation as resolved.
Show resolved
Hide resolved
|
||
eccentricity.vec[indices] = max(eccentricity.vec) - eccentricity.vec[indices] | ||
## Construct centrality dataframe | ||
centrality.dataframe = data.frame(author.name = names(eccentricity.vec), | ||
centrality = as.vector(eccentricity.vec)) | ||
} else if (type == "commit.count") { | ||
## Construct centrality dataframe | ||
centrality.dataframe = get.author.commit.count(proj.data) | ||
|
@@ -669,6 +703,50 @@ get.author.class.network.hierarchy = function(network, result.limit = NULL, | |
return(result) | ||
} | ||
|
||
get.author.class.network.betweenness = function(network, result.limit = NULL, | ||
restrict.classification.to.authors = NULL) { | ||
Leo-Send marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logging::logdebug("get.author.class.network.betweenness: starting.") | ||
|
||
result = get.author.class.by.type(network = network, type = "network.betweenness", result.limit = result.limit, | ||
restrict.classification.to.authors = restrict.classification.to.authors) | ||
|
||
logging::logdebug("get.author.class.network.betweenness: finished.") | ||
return(result) | ||
} | ||
|
||
get.author.class.network.closeness = function(network, result.limit = NULL, | ||
restrict.classification.to.authors = NULL) { | ||
logging::logdebug("get.author.class.network.closeness: starting.") | ||
|
||
result = get.author.class.by.type(network = network, type = "network.closeness", result.limit = result.limit, | ||
restrict.classification.to.authors = restrict.classification.to.authors) | ||
|
||
logging::logdebug("get.author.class.network.closeness: finished.") | ||
return(result) | ||
} | ||
|
||
get.author.class.network.pagerank = function(network, result.limit = NULL, | ||
restrict.classification.to.authors = NULL) { | ||
logging::logdebug("get.author.class.network.pagerank: starting.") | ||
|
||
result = get.author.class.by.type(network = network, type = "network.pagerank", result.limit = result.limit, | ||
restrict.classification.to.authors = restrict.classification.to.authors) | ||
|
||
logging::logdebug("get.author.class.network.pagerank: finished.") | ||
return(result) | ||
} | ||
|
||
get.author.class.network.eccentricity = function(network, result.limit = NULL, | ||
restrict.classification.to.authors = NULL) { | ||
logging::logdebug("get.author.class.network.eccentricity: starting.") | ||
|
||
result = get.author.class.by.type(network = network, type = "network.eccentricity", result.limit = result.limit, | ||
restrict.classification.to.authors = restrict.classification.to.authors) | ||
|
||
logging::logdebug("get.author.class.network.eccentricity: finished.") | ||
return(result) | ||
} | ||
|
||
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / | ||
## Count-based classification --------------------------------------------- | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 also update the copyright header here - some of your last changes have been added in 2025.