Metadata-Version: 2.4
Name: netseg
Version: 0.1.6
Summary: netseg is a python package for measuring segregation and structural polarization in social networks.
Author-email: Onur Tuncay Bal <onurtuncaybal@gmail.com>
Project-URL: Homepage, https://codeberg.org/onurB/netseg
Project-URL: Bug Tracker, https://codeberg.org/OnurB/netseg/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: igraph
Requires-Dist: numpy
Requires-Dist: scipy
Dynamic: license-file

# netseg
<img src="assets/netseg-logo.png" align="right" width="150" alt="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](https://mbojan.github.io/netseg/) (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](https://igraph.org/) and [NumPy](https://numpy.org/) , 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 

```{bash}
pip install netseg
```

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

```{bash}
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.](https://onurb.codeberg.page/netseg/)




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