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.8

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.8
File Size Uploaded
netseg-0.1.8.tar.gz 52.2 kB Details

Built distribution (wheel)

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

Total release size: 92.1 kB

Release files / netseg-0.1.8.tar.gz

Download URL netseg-0.1.8.tar.gz
Size 52.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0310aa755e1ee5be8829e5ec7eace4a845402de5f25dd2a7896b39b789cddc4e
BLAKE2b-256 checksum
How to use checksums
5b4b083f3b33052a20782404d72fa447c47823401d768d69e1823157e3155599
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.8-py3-none-any.whl

Download URL netseg-0.1.8-py3-none-any.whl
Size 39.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee1c1bed3c1296d905f094d946483325d430b4ac85a29becd068ec4172a2f661
BLAKE2b-256 checksum
How to use checksums
4c39b456b6489e96d990b04166ab3da9b5456d2304d01f4ce32098f8716429b7
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

This release

0.1.8 This release

2 release files

0.1.7

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