Skip to main content

netseg

CI PyPI Python versions License Docs netseg logo

netseg is a Python package for measuring segregation and structural polarization in social networks.

This package extends and complements the original netseg R package (Bojanowski & Corten, 2014; Bojanowski, 2025), which introduced the unified framework for measuring network segregation. The Python port and additional polarization measures were developed, with new features subsequently integrated into both packages.

It was developed to address several key gaps in the current Python ecosystem:

  • A Unified Framework: While analyzing network segregation and polarization is common, the myriad of existing measures makes cross-network comparisons exceedingly difficult. netseg provides a centralized toolkit for standardizing these measurements.

  • Extensively Documented: netseg is extensively documented. From various case by case usage examples to the advanced null-model selection, it offers a clear guide for your research.

  • Advanced Null-Model Comparison: Many existing approaches rely on purely random graphs to quantify excess polarization or segregation, a notoriously low baseline. netseg allows you to use customized network ensembles as null models, enabling robust, comparative segregation analysis.

  • Extensions and Improved Optimization netseg offers extensions for already existing measures, calculating the structural polarization and segregation in directed and undirected networks with multiple groups. netseg is build on igraph and NumPy , it offers near bare-metal speed with NumPy's vectorization and igraph's C backend.

Support and Contact

If you come across any issues, please visit the repository page https://codeberg.org/OnurB/netseg. Suggestions & Discussions: bal_onur@phd.ceu.edu

netseg R package is maintained at https://mbojan.github.io/netseg/.

Installation

You can install netseg through PyPI with

pip install netseg

Or you can install directly from the source without the blobs with

git clone --filter=blob:none --sparse https://codeberg.org/OnurB/netseg.git
cd netseg
git sparse-checkout set src
pip install .

Documentation

You can reach to the documentation here. The rendered documentation is served from Codeberg Pages (and will stay here due to ethical reasons). That service is independent of codeberg.org and occasionally unavailable while the repository itself remains reachable. The same built HTML lives on the pages branch, so you can always read the docs locally:

git clone --branch pages --single-branch --depth 1 https://codeberg.org/OnurB/netseg.git netseg-docs
cd netseg-docs
python3 -m http.server 8000

Then open http://localhost:8000.

Citation

If you are using netseg, please cite as:

Bal, O. T., & Bojanowski, M. (2026). netseg: A Python package for measuring structural polarization and segregation in social networks (arXiv:2609.16088). arXiv. https://doi.org/10.48550/arXiv.2609.16088

or as BibTeX:

@misc{bal2026netsegpythonpackagemeasuring,
      title={netseg: a Python Package for Measuring Structural Polarization and Segregation in Social Networks}, 
      author={Onur Tuncay Bal and Michał Bojanowski},
      year={2026},
      eprint={2609.16088},
      archivePrefix={arXiv},
      primaryClass={cs.SI},
      url={https://arxiv.org/abs/2609.16088}, 
}

References

Bojanowski M (2025). Measures of Network Segregation and Homophily. R package version 1.0-3, https://mbojan.github.io/netseg/.

Bojanowski M, Corten R (2014). “Measuring Segregation in Social Networks.” Social Networks, 39, 14-32. doi:10.1016/j.socnet.2014.04.001 https://doi.org/10.1016/j.socnet.2014.04.001.

Metadata

Release files for netseg 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netseg 0.1.7
File Size Uploaded
netseg-0.1.7.tar.gz 50.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for netseg 0.1.7
File Interpreter ABI Platform
netseg-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 89.6 kB

Release files / netseg-0.1.7.tar.gz

Download URL netseg-0.1.7.tar.gz
Size 50.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a51629d8c3e5aec7858051910e57d7eb5cde057676cb47b9cb91b8cff8ccaf77
BLAKE2b-256 checksum
How to use checksums
5b7c20a9f73fac4bad67a16c569a3f90064927a31c6ba2d55519d63b3c631af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / netseg-0.1.7-py3-none-any.whl

Download URL netseg-0.1.7-py3-none-any.whl
Size 39.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a075167a49f668d6c5e7745f01d655726e766f7cc4d459dc7e97c0d6d31ff212
BLAKE2b-256 checksum
How to use checksums
01b3ded00a348ffe22d9b0b1a8dfee642cf3be23355720406a8f893989d56ce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

0.1.8

2 release files

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page