netrankr
netrankr: An R package for total, partial, and probabilistic rankings in networks - Published in JOSS (2022)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 18 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
1 of 7 committers (14.3%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
network-analysis
network-centrality
r-package
Keywords from Contributors
ggraph
graph-algorithms
network-visualization
Scientific Fields
Medicine
Life Sciences -
40% confidence
Psychology
Social Sciences -
40% confidence
Last synced: 6 months ago
·
JSON representation
·
Repository
An R package for network centrality
Basic Info
- Host: GitHub
- Owner: schochastics
- License: other
- Language: R
- Default Branch: main
- Homepage: https://schochastics.github.io/netrankr/
- Size: 24.5 MB
Statistics
- Stars: 49
- Watchers: 5
- Forks: 5
- Open Issues: 0
- Releases: 9
Topics
network-analysis
network-centrality
r-package
Created almost 9 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Citation
README.Rmd
--- output: github_document --- # netrankr[](https://github.com/schochastics/netrankr/actions/workflows/R-CMD-check.yaml) [](https://cran.r-project.org/package=netrankr) [](https://CRAN.R-project.org/package=netrankr) [](https://app.codecov.io/gh/schochastics/netrankr?branch=main) [](https://doi.org/10.21105/joss.04563) [](https://doi.org/10.5281/zenodo.7109041) ```{r setup, include=FALSE} knitr::opts_chunk$set( collapse = TRUE, fig.align = "center", out.width = "80%", comment = "#>", fig.path = "man/figures/README-", echo = TRUE, warning = FALSE, message = FALSE ) ``` ## Overview The literature is flooded with centrality indices and new ones are introduced on a regular basis. Although there exist several theoretical and empirical guidelines on when to use certain indices, there still exists plenty of ambiguity in the concept of network centrality. To date, network centrality is nothing more than applying indices to a network:  The only degree of freedom is the choice of index. The package comes with an Rstudio addin (`index_builder()`), which allows to build or choose from more than 20 different indices. Blindly (ab)using this function is highly discouraged! The `netrankr` package is based on the idea that centrality is more than a conglomeration of indices. Decomposing them in a series of microsteps offers the posibility to gradually add ideas about centrality, without succumbing to trial-and-error approaches. Further, it allows for alternative assessment methods which can be more general than the index-driven approach:  The new approach is centered around the concept of *positions*, which are defined as the relations and potential attributes of a node in a network. The aggregation of the relations leads to the definition of indices. However, positions can also be compared via *positional dominance*, leading to partial centrality rankings and the option to calculate probabilistic centrality rankings. For a more detailed theoretical background, consult the [Literature](#literature) at the end of this page. ________________________________________________________________________________ ## Installation To install from CRAN: ```{r install_cran, eval=FALSE} install.packages("netrankr") ``` To install the developer version from github: ```{r install_git, eval=FALSE} # install.packages("remotes") remotes::install_github("schochastics/netrankr") ``` ________________________________________________________________________________ ## Simple Example This example briefly explains some of the functionality of the package and the difference to an index driven approach. For a more realistic application see the use case vignette. We work with the following small graph. ```{r example_graph, warning=FALSE,message=FALSE} library(igraph) library(netrankr) data("dbces11") g <- dbces11 ``` ```{r dbces_neutral, echo=FALSE} library(ggraph) V(g)$name <- as.character(1:11) ggraph(g, "stress") + geom_edge_link0(edge_colour = "grey66") + geom_node_point(shape = 21, fill = "grey25", size = 8) + geom_node_text(aes(label = name), col = "white") + theme_graph() ``` Say we are interested in the most central node of the graph and simply compute some standard centrality scores with the `igraph` package. Defining centrality indices in the `netrankr` package is explained in the centrality indices vignette. ```{r cent,warning=FALSE} cent_scores <- data.frame( degree = degree(g), betweenness = round(betweenness(g), 4), closeness = round(closeness(g), 4), eigenvector = round(eigen_centrality(g)$vector, 4), subgraph = round(subgraph_centrality(g), 4) ) # What are the most central nodes for each index? apply(cent_scores, 2, which.max) ``` ```{r dbces_color, echo=FALSE} V(g)$col <- "none" V(g)$col[apply(cent_scores, 2, which.max)] <- names(apply(cent_scores, 2, which.max)) V(g)$lab <- "" V(g)$lab[apply(cent_scores, 2, which.max)] <- stringr::str_to_upper(stringr::str_extract(names(apply(cent_scores, 2, which.max)), "^[a-z]")) ggraph(g, "stress") + geom_edge_link0(edge_colour = "grey66") + geom_node_point(aes(fill = col), shape = 21, size = 8) + geom_node_text(aes(label = lab), col = "white") + scale_fill_manual(values = c("#1874CD", "#CD2626", "#EEB422", "#9A32CD", "#4D4D4D", "#EE30A7")) + theme_graph() + theme(legend.position = "none") ``` As you can see, each index assigns the highest value to a different vertex. A more general assessment starts by calculating the neighborhood inclusion preorder. ```{r ex_ni} P <- neighborhood_inclusion(g) P ``` [Schoch & Brandes (2016)](https://doi.org/10.1017/S0956792516000401) showed that `P[u,v]=1` implies that u is less central than v for centrality indices which are defined via specific path algebras. These include many of the well-known measures like closeness (and variants), betweenness (and variants) as well as many walk-based indices (eigenvector and subgraph centrality, total communicability,...). Neighborhood-inclusion defines a partial ranking on the set of nodes. Each ranking that is in accordance with this partial ranking yields a proper centrality ranking. Each of these ranking can thus potentially be the outcome of a centrality index. Using rank intervals, we can examine the minimal and maximal possible rank of each node. The bigger the intervals are, the more freedom exists for indices to rank nodes differently. ```{r partial} plot(rank_intervals(P), cent_scores = cent_scores, ties.method = "average") ``` The potential ranks of nodes are not uniformly distributed in the intervals. To get the exact probabilities, the function `exact_rank_prob()` can be used. ```{r ex_p} res <- exact_rank_prob(P) res ``` For the graph `g` we can therefore come up with `r format(res$lin.ext,big.mark = ",")` indices that would rank the nodes differently. `rank.prob` contains the probabilities for each node to occupy a certain rank. For instance, the probability for each node to be the most central one is as follows. ```{r most_central} round(res$rank.prob[, 11], 2) ``` `relative.rank` contains the relative rank probabilities. An entry `relative.rank[u,v]` indicates how likely it is that `v` is more central than `u`. ```{r rel_rank} # How likely is it, that 6 is more central than 3? round(res$relative.rank[3, 6], 2) ``` `expected.ranks` contains the expected centrality ranks for all nodes. They are derived on the basis of `rank.prob`. ```{r exp_rank} round(res$expected.rank, 2) ``` The higher the value, the more central a node is expected to be. **Note**: The set of rankings grows exponentially in the number of nodes and the exact calculation becomes infeasible quite quickly and approximations need to be used. Check the benchmark results for guidelines. ________________________________________________________________________________ ## Theoretical Background {#literature} `netrankr` is based on a series of papers that appeared in recent years. If you want to learn more about the theoretical background of the package, consult the following literature: > Schoch, David. (2018). Centrality without Indices: Partial rankings and rank Probabilities in networks. *Social Networks*, **54**, 50-60.([link](https://doi.org/10.1016/j.socnet.2017.12.003)) > Schoch, David & Valente, Thomas W., & Brandes, Ulrik. (2017). Correlations among centrality indices and a class of uniquely ranked graphs. *Social Networks*, **50**, 46-54.([link](https://doi.org/10.1016/j.socnet.2017.03.010)) > Schoch, David & Brandes, Ulrik. (2016). Re-conceptualizing centrality in social networks. *European Journal of Appplied Mathematics*, **27**(6), 971–985. ([link](https://doi.org/10.1017/S0956792516000401)) > Brandes, Ulrik. (2016). Network Positions. *Methodological Innovations*, **9**, 2059799116630650. ([link](https://dx.doi.org/10.1177/2059799116630650)) ## Code of Conduct Please note that the netrankr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Owner
- Name: David Schoch
- Login: schochastics
- Kind: user
- Location: Germany
- Company: cynkra
- Website: mr.schochastics.net
- Repositories: 131
- Profile: https://github.com/schochastics
Data Scientist/DevOps Engineer at cynkra and #RStats developer
JOSS Publication
netrankr: An R package for total, partial, and probabilistic rankings in networks
Published
September 26, 2022
Volume 7, Issue 77, Page 4563
Tags
network analysis network centrality partial ordersCitation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "netrankr" in publications use:'
type: software
license: MIT
title: 'netrankr: Analyzing Partial Rankings in Networks'
version: 1.2.3
identifiers:
- type: doi
value: 10.32614/CRAN.package.netrankr
- type: url
value: https://schochastics.github.io/netrankr/
abstract: Implements methods for centrality related analyses of networks. While the
package includes the possibility to build more than 20 indices, its main focus lies
on index-free assessment of centrality via partial rankings obtained by neighborhood-inclusion
or positional dominance. These partial rankings can be analyzed with different methods,
including probabilistic methods like computing expected node ranks and relative
rank probabilities (how likely is it that a node is more central than another?).
The methodology is described in depth in the vignettes and in Schoch (2018) <https://doi.org/10.1016/j.socnet.2017.12.003>.
authors:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
preferred-citation:
type: article
title: 'netrankr: An R package for total, partial, and probabilistic rankings in
networks'
authors:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
journal: Journal of Open Source Software
issue: '77'
year: '2022'
start: '4563'
repository: https://CRAN.R-project.org/package=netrankr
repository-code: https://github.com/schochastics/netrankr
url: https://github.com/schochastics/netrankr/
contact:
- family-names: Schoch
given-names: David
email: david@schochastics.net
orcid: https://orcid.org/0000-0003-2952-4812
keywords:
- network-analysis
- network-centrality
- r-package
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 3.0.1'
- type: software
title: igraph
abstract: 'igraph: Network Analysis and Visualization'
notes: Imports
url: https://r.igraph.org/
repository: https://CRAN.R-project.org/package=igraph
authors:
- family-names: Csárdi
given-names: Gábor
email: csardi.gabor@gmail.com
orcid: https://orcid.org/0000-0001-7098-9676
- family-names: Nepusz
given-names: Tamás
email: ntamas@gmail.com
orcid: https://orcid.org/0000-0002-1451-338X
- family-names: Traag
given-names: Vincent
orcid: https://orcid.org/0000-0003-3170-3879
- family-names: Horvát
given-names: Szabolcs
email: szhorvat@gmail.com
orcid: https://orcid.org/0000-0002-3100-523X
- family-names: Zanini
given-names: Fabio
email: fabio.zanini@unsw.edu.au
orcid: https://orcid.org/0000-0001-7097-8539
- family-names: Noom
given-names: Daniel
- family-names: Müller
given-names: Kirill
email: kirill@cynkra.com
orcid: https://orcid.org/0000-0002-1416-3412
year: '2024'
doi: 10.32614/CRAN.package.igraph
version: '>= 1.0.1'
- type: software
title: Rcpp
abstract: 'Rcpp: Seamless R and C++ Integration'
notes: Imports
url: https://www.rcpp.org
repository: https://CRAN.R-project.org/package=Rcpp
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Allaire
given-names: JJ
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Ushey
given-names: Kevin
orcid: https://orcid.org/0000-0003-2880-7407
- family-names: Kou
given-names: Qiang
orcid: https://orcid.org/0000-0001-6786-5453
- family-names: Russell
given-names: Nathan
- family-names: Ucar
given-names: Iñaki
orcid: https://orcid.org/0000-0001-6403-5550
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Chambers
given-names: John
year: '2024'
doi: 10.32614/CRAN.package.Rcpp
version: '>= 0.12.8'
- type: software
title: Matrix
abstract: 'Matrix: Sparse and Dense Matrix Classes and Methods'
notes: Imports
url: https://R-forge.R-project.org/tracker/?atid=294&group_id=61
repository: https://CRAN.R-project.org/package=Matrix
authors:
- family-names: Bates
given-names: Douglas
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Maechler
given-names: Martin
email: mmaechler+Matrix@gmail.com
orcid: https://orcid.org/0000-0002-8685-9910
- family-names: Jagan
given-names: Mikael
orcid: https://orcid.org/0000-0002-3542-2938
year: '2024'
doi: 10.32614/CRAN.package.Matrix
- type: software
title: Rcpp
abstract: 'Rcpp: Seamless R and C++ Integration'
notes: Imports
url: https://www.rcpp.org
repository: https://CRAN.R-project.org/package=Rcpp
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Allaire
given-names: JJ
orcid: https://orcid.org/0000-0003-0174-9868
- family-names: Ushey
given-names: Kevin
orcid: https://orcid.org/0000-0003-2880-7407
- family-names: Kou
given-names: Qiang
orcid: https://orcid.org/0000-0001-6786-5453
- family-names: Russell
given-names: Nathan
- family-names: Ucar
given-names: Iñaki
orcid: https://orcid.org/0000-0001-6403-5550
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Chambers
given-names: John
year: '2024'
doi: 10.32614/CRAN.package.Rcpp
- type: software
title: RcppArmadillo
abstract: 'RcppArmadillo: ''Rcpp'' Integration for the ''Armadillo'' Templated Linear
Algebra Library'
notes: LinkingTo
url: https://dirk.eddelbuettel.com/code/rcpp.armadillo.html
repository: https://CRAN.R-project.org/package=RcppArmadillo
authors:
- family-names: Eddelbuettel
given-names: Dirk
email: edd@debian.org
orcid: https://orcid.org/0000-0001-6419-907X
- family-names: Francois
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Bates
given-names: Doug
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Ni
given-names: Binxiang
- family-names: Sanderson
given-names: Conrad
orcid: https://orcid.org/0000-0002-0049-4501
year: '2024'
doi: 10.32614/CRAN.package.RcppArmadillo
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
notes: Suggests
url: https://yihui.org/knitr/
repository: https://CRAN.R-project.org/package=knitr
authors:
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
doi: 10.32614/CRAN.package.knitr
- type: software
title: rmarkdown
abstract: 'rmarkdown: Dynamic Documents for R'
notes: Suggests
url: https://pkgs.rstudio.com/rmarkdown/
repository: https://CRAN.R-project.org/package=rmarkdown
authors:
- family-names: Allaire
given-names: JJ
email: jj@posit.co
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
- family-names: Dervieux
given-names: Christophe
email: cderv@posit.co
orcid: https://orcid.org/0000-0003-4474-2498
- family-names: McPherson
given-names: Jonathan
email: jonathan@posit.co
- family-names: Luraschi
given-names: Javier
- family-names: Ushey
given-names: Kevin
email: kevin@posit.co
- family-names: Atkins
given-names: Aron
email: aron@posit.co
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
- family-names: Cheng
given-names: Joe
email: joe@posit.co
- family-names: Chang
given-names: Winston
email: winston@posit.co
- family-names: Iannone
given-names: Richard
email: rich@posit.co
orcid: https://orcid.org/0000-0003-3925-190X
year: '2024'
doi: 10.32614/CRAN.package.rmarkdown
- type: software
title: magrittr
abstract: 'magrittr: A Forward-Pipe Operator for R'
notes: Suggests
url: https://magrittr.tidyverse.org
repository: https://CRAN.R-project.org/package=magrittr
authors:
- family-names: Bache
given-names: Stefan Milton
email: stefan@stefanbache.dk
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
year: '2024'
doi: 10.32614/CRAN.package.magrittr
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
url: https://testthat.r-lib.org
repository: https://CRAN.R-project.org/package=testthat
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2024'
doi: 10.32614/CRAN.package.testthat
- type: software
title: shiny
abstract: 'shiny: Web Application Framework for R'
notes: Suggests
url: https://shiny.posit.co/
repository: https://CRAN.R-project.org/package=shiny
authors:
- family-names: Chang
given-names: Winston
email: winston@posit.co
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Cheng
given-names: Joe
email: joe@posit.co
- family-names: Allaire
given-names: JJ
email: jj@posit.co
- family-names: Sievert
given-names: Carson
email: carson@posit.co
orcid: https://orcid.org/0000-0002-4958-2844
- family-names: Schloerke
given-names: Barret
email: barret@posit.co
orcid: https://orcid.org/0000-0001-9986-114X
- family-names: Xie
given-names: Yihui
email: yihui@posit.co
- family-names: Allen
given-names: Jeff
- family-names: McPherson
given-names: Jonathan
email: jonathan@posit.co
- family-names: Dipert
given-names: Alan
- family-names: Borges
given-names: Barbara
year: '2024'
doi: 10.32614/CRAN.package.shiny
version: '>= 0.13'
- type: software
title: miniUI
abstract: 'miniUI: Shiny UI Widgets for Small Screens'
notes: Suggests
repository: https://CRAN.R-project.org/package=miniUI
authors:
- family-names: Cheng
given-names: Joe
email: joe@rstudio.com
year: '2024'
doi: 10.32614/CRAN.package.miniUI
version: '>= 0.1.1'
- type: software
title: rstudioapi
abstract: 'rstudioapi: Safely Access the RStudio API'
notes: Suggests
url: https://rstudio.github.io/rstudioapi/
repository: https://CRAN.R-project.org/package=rstudioapi
authors:
- family-names: Ushey
given-names: Kevin
email: kevin@rstudio.com
- family-names: Allaire
given-names: JJ
email: jj@posit.co
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
- family-names: Ritchie
given-names: Gary
email: gary@posit.co
year: '2024'
doi: 10.32614/CRAN.package.rstudioapi
version: '>= 0.5'
GitHub Events
Total
- Release event: 1
- Watch event: 2
- Issue comment event: 1
- Push event: 9
- Pull request event: 5
- Create event: 2
Last Year
- Release event: 1
- Watch event: 2
- Issue comment event: 1
- Push event: 9
- Pull request event: 5
- Create event: 2
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| schochastics | d****h@u****e | 299 |
| schochastics | d****d@s****t | 103 |
| d-mathlete | d****a@g****m | 64 |
| Mehmet Hakan Satman | m****n@g****m | 3 |
| Luis Verde Arregoitia | l****d@c****x | 2 |
| Arthur Mühl | a****l@g****g | 2 |
| Raniere Silva | R****a@g****g | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 19
- Total pull requests: 9
- Average time to close issues: 12 months
- Average time to close pull requests: 4 days
- Total issue authors: 6
- Total pull request authors: 5
- Average comments per issue: 0.95
- Average comments per pull request: 0.22
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: 6 days
- Issue authors: 0
- Pull request authors: 3
- Average comments per issue: 0
- Average comments per pull request: 0.4
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- corybrunson (8)
- schochastics (7)
- barracuda156 (1)
- tedmoorman (1)
- mbojan (1)
- TomKellyGenetics (1)
Pull Request Authors
- schochastics (3)
- ArthurMuehl (2)
- jbytecode (2)
- luisDVA (2)
- rgaiacs (1)
Top Labels
Issue Labels
enhancement (3)
bug (2)
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 1,150 last-month
- Total docker downloads: 56
-
Total dependent packages: 2
(may contain duplicates) -
Total dependent repositories: 2
(may contain duplicates) - Total versions: 17
- Total maintainers: 1
cran.r-project.org: netrankr
Analyzing Partial Rankings in Networks
- Homepage: https://github.com/schochastics/netrankr/
- Documentation: http://cran.r-project.org/web/packages/netrankr/netrankr.pdf
- License: MIT + file LICENSE
-
Latest release: 1.2.4
published about 1 year ago
Rankings
Stargazers count: 7.1%
Downloads: 10.6%
Average: 12.9%
Dependent packages count: 13.7%
Forks count: 14.2%
Dependent repos count: 19.2%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: r-netrankr
- Homepage: https://schochastics.github.io/netrankr
- License: MIT
-
Latest release: 1.2.0
published over 3 years ago
Rankings
Dependent repos count: 34.0%
Stargazers count: 38.3%
Average: 44.4%
Dependent packages count: 51.2%
Forks count: 54.2%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.0.1 depends
- Matrix * imports
- Rcpp >= 0.12.8 imports
- igraph >= 1.0.1 imports
- knitr * suggests
- magrittr * suggests
- miniUI >= 0.1.1 suggests
- rmarkdown * suggests
- rstudioapi >= 0.5 suggests
- shiny >= 0.13 suggests
- testthat * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
[](https://github.com/schochastics/netrankr/actions/workflows/R-CMD-check.yaml)
[](https://cran.r-project.org/package=netrankr)
[](https://CRAN.R-project.org/package=netrankr)
[](https://app.codecov.io/gh/schochastics/netrankr?branch=main)
[](https://doi.org/10.21105/joss.04563)
[](https://doi.org/10.5281/zenodo.7109041)
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.align = "center",
out.width = "80%",
comment = "#>",
fig.path = "man/figures/README-",
echo = TRUE,
warning = FALSE,
message = FALSE
)
```
## Overview
The literature is flooded with centrality indices and new ones are introduced
on a regular basis. Although there exist several theoretical and empirical guidelines
on when to use certain indices, there still exists plenty of ambiguity in the concept
of network centrality. To date, network centrality is nothing more than applying indices
to a network:

The only degree of freedom is the choice of index. The package comes with an Rstudio addin (`index_builder()`),
which allows to build or choose from more than 20 different indices. Blindly (ab)using
this function is highly discouraged!
The `netrankr` package is based on the idea that centrality is more than a
conglomeration of indices. Decomposing them in a series of microsteps offers
the posibility to gradually add ideas about centrality, without succumbing to
trial-and-error approaches. Further, it allows for alternative assessment methods
which can be more general than the index-driven approach:

The new approach is centered around the concept of *positions*, which are defined as
the relations and potential attributes of a node in a network. The aggregation
of the relations leads to the definition of indices. However, positions can also
be compared via *positional dominance*, leading to partial centrality rankings and
the option to calculate probabilistic centrality rankings.
For a more detailed theoretical background, consult the [Literature](#literature)
at the end of this page.
________________________________________________________________________________
## Installation
To install from CRAN:
```{r install_cran, eval=FALSE}
install.packages("netrankr")
```
To install the developer version from github:
```{r install_git, eval=FALSE}
# install.packages("remotes")
remotes::install_github("schochastics/netrankr")
```
________________________________________________________________________________
## Simple Example
This example briefly explains some of the functionality of the package and the
difference to an index driven approach. For a more realistic application see
the use case vignette.
We work with the following small graph.
```{r example_graph, warning=FALSE,message=FALSE}
library(igraph)
library(netrankr)
data("dbces11")
g <- dbces11
```
```{r dbces_neutral, echo=FALSE}
library(ggraph)
V(g)$name <- as.character(1:11)
ggraph(g, "stress") +
geom_edge_link0(edge_colour = "grey66") +
geom_node_point(shape = 21, fill = "grey25", size = 8) +
geom_node_text(aes(label = name), col = "white") +
theme_graph()
```
Say we are interested in the most central node of the graph and simply compute some
standard centrality scores with the `igraph` package. Defining centrality indices
in the `netrankr` package is explained in the centrality indices vignette.
```{r cent,warning=FALSE}
cent_scores <- data.frame(
degree = degree(g),
betweenness = round(betweenness(g), 4),
closeness = round(closeness(g), 4),
eigenvector = round(eigen_centrality(g)$vector, 4),
subgraph = round(subgraph_centrality(g), 4)
)
# What are the most central nodes for each index?
apply(cent_scores, 2, which.max)
```
```{r dbces_color, echo=FALSE}
V(g)$col <- "none"
V(g)$col[apply(cent_scores, 2, which.max)] <- names(apply(cent_scores, 2, which.max))
V(g)$lab <- ""
V(g)$lab[apply(cent_scores, 2, which.max)] <- stringr::str_to_upper(stringr::str_extract(names(apply(cent_scores, 2, which.max)), "^[a-z]"))
ggraph(g, "stress") +
geom_edge_link0(edge_colour = "grey66") +
geom_node_point(aes(fill = col), shape = 21, size = 8) +
geom_node_text(aes(label = lab), col = "white") +
scale_fill_manual(values = c("#1874CD", "#CD2626", "#EEB422", "#9A32CD", "#4D4D4D", "#EE30A7")) +
theme_graph() +
theme(legend.position = "none")
```
As you can see, each index assigns the highest value to a different vertex.
A more general assessment starts by calculating the neighborhood inclusion preorder.
```{r ex_ni}
P <- neighborhood_inclusion(g)
P
```
[Schoch & Brandes (2016)](https://doi.org/10.1017/S0956792516000401) showed that
`P[u,v]=1` implies that u is less central than v for
centrality indices which are defined via specific path algebras. These include
many of the well-known measures like closeness (and variants), betweenness (and variants)
as well as many walk-based indices (eigenvector and subgraph centrality, total communicability,...).
Neighborhood-inclusion defines a partial ranking on the set of nodes. Each ranking
that is in accordance with this partial ranking yields a proper centrality ranking.
Each of these ranking can thus potentially be the outcome of a centrality index.
Using rank intervals, we can examine the minimal and maximal possible rank of each node.
The bigger the intervals are, the more freedom exists for indices to rank nodes differently.
```{r partial}
plot(rank_intervals(P), cent_scores = cent_scores, ties.method = "average")
```
The potential ranks of nodes are not uniformly distributed in the intervals. To get
the exact probabilities, the function `exact_rank_prob()` can be used.
```{r ex_p}
res <- exact_rank_prob(P)
res
```
For the graph `g` we can therefore come up with
`r format(res$lin.ext,big.mark = ",")` indices that would rank the nodes differently.
`rank.prob` contains the probabilities for each node to occupy a certain rank.
For instance, the probability for each node to be the most central one is as follows.
```{r most_central}
round(res$rank.prob[, 11], 2)
```
`relative.rank` contains the relative rank probabilities. An entry `relative.rank[u,v]`
indicates how likely it is that `v` is more central than `u`.
```{r rel_rank}
# How likely is it, that 6 is more central than 3?
round(res$relative.rank[3, 6], 2)
```
`expected.ranks` contains the expected centrality ranks for all nodes. They are
derived on the basis of `rank.prob`.
```{r exp_rank}
round(res$expected.rank, 2)
```
The higher the value, the more central a node is expected to be.
**Note**: The set of rankings grows exponentially in the number of nodes and the exact
calculation becomes infeasible quite quickly and approximations need to be used.
Check the benchmark results for guidelines.
________________________________________________________________________________
## Theoretical Background {#literature}
`netrankr` is based on a series of papers that appeared in recent years. If you
want to learn more about the theoretical background of the package,
consult the following literature:
> Schoch, David. (2018). Centrality without Indices: Partial rankings and rank
Probabilities in networks. *Social Networks*, **54**, 50-60.([link](https://doi.org/10.1016/j.socnet.2017.12.003))
> Schoch, David & Valente, Thomas W., & Brandes, Ulrik. (2017). Correlations among centrality indices
and a class of uniquely ranked graphs. *Social Networks*, **50**, 46-54.([link](https://doi.org/10.1016/j.socnet.2017.03.010))
> Schoch, David & Brandes, Ulrik. (2016). Re-conceptualizing centrality in social networks.
*European Journal of Appplied Mathematics*, **27**(6), 971–985.
([link](https://doi.org/10.1017/S0956792516000401))
> Brandes, Ulrik. (2016). Network Positions.
*Methodological Innovations*, **9**, 2059799116630650.
([link](https://dx.doi.org/10.1177/2059799116630650))
## Code of Conduct
Please note that the netrankr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
