Skip to main content

NetSegPol

This repository provides a lightweight, object-oriented Python toolkit for computing structural polarization and segregation measures in networks. It implements a wide range of classical and modern network mixing, segregation, and polarization indices used in sociology, computational social science, and network science.

How to use?

You should not use descriptive measures without a null-model.

from netsegpol import Measurer

edges = [
    # Group 0 
    (0, 1), (0, 2), (1, 2), (1, 3),
    (2, 3), (2, 4), (3, 4), (0, 4),

    # Group 1 
    (5, 6), (5, 7), (6, 7), (6, 8),
    (7, 8), (7, 9), (8, 9), (5, 9),

    # Sparse inter-group edges
    (2, 6), (3, 7), (1, 8), (4, 9)
]

membership = {
    0: 0, 1: 0, 2: 0, 3: 0, 4: 0,
    5: 1, 6: 1, 7: 1, 8: 1, 9: 1
}

measurer = Measurer(edges, 
                    membership,
                    directed = False,
                    safe_create = True)

print(measurer.segregation_matrix_index()) # or the function that you want to use

What should I be careful of?

You should be careful if you are using an external package like igraph and getting the edge list directly since indexing methods might differ and your edgelist and membership dictionary might not match.

Will there be new measures?

This is still a project in its infancy, hence a few of the measures will be developed later on, such as Ergodic Markov Chain mixing time or Spectral Segregation etc.

Metadata

Release files for netsegpol 0.1.0

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

Source distribution (sdist)

Source distribution for netsegpol 0.1.0
File Size Uploaded
netsegpol-0.1.0.tar.gz 13.4 kB Details

Built distribution (wheel)

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

Total release size: 26.3 kB

Release files / netsegpol-0.1.0.tar.gz

Download URL netsegpol-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
03912580ce86f7177f2105e84b28769771c9e6319b824767d3c5368cf67ecb12
BLAKE2b-256 checksum
How to use checksums
490cfe026737e2e4de0be7a2559104266ad60ad5fc50d8436286a2f1d9a4aa03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / netsegpol-0.1.0-py3-none-any.whl

Download URL netsegpol-0.1.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
557b096396a9b733afcc7f42c906c33b70e783f84d4c73ccb479612276d409aa
BLAKE2b-256 checksum
How to use checksums
d4ba157e6824e62f3f40db81b5ab15d0a108d17497fe310378c4c64b2fbf7bee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

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