Skip to main content

netseg

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.

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

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.6
File Size Uploaded
netseg-0.1.6.tar.gz 45.6 kB Details

Built distribution (wheel)

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

Total release size: 83.3 kB

Release files / netseg-0.1.6.tar.gz

Download URL netseg-0.1.6.tar.gz
Size 45.6 kB
Tags Source
SHA-256 checksum
How to use checksums
786703d81045c85452b4d4b8cf04f4b9252be9ea4e3d76fdd40a2b7cd3b2f39c
BLAKE2b-256 checksum
How to use checksums
ce70bb75378fd458d2b9edb16bb4de8abe8e7b5f34a6e6278b607898f6591052
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.6-py3-none-any.whl

Download URL netseg-0.1.6-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e876e66ca750d7f436413669aa02caaa1bcc9f311040114c5b269be072f8bd3
BLAKE2b-256 checksum
How to use checksums
92bcd6ad58631a142d2971614d2ec45b34223d410aa4034a7315667d3c713868
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

0.1.7

2 release files

This release

0.1.6 This release

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