Skip to main content

license package publish

CIGA: Character Interaction Graph Analysis

CIGA analyzes character interactions over time. Use graphs for pairwise relationships, or hypergraphs to keep a group interaction as one event. It builds on igraph and is a redesign of CharNet.

Getting started · Documentation · Upgrade roadmap · Contributing

Install

This documentation targets CIGA 0.1.5 (Python 3.9+). After its PyPI release:

python -m pip install "ciga==0.1.5"

To use the source checkout, including before publication:

git clone https://github.com/MediaCompLab/ciga.git
cd ciga
python -m pip install -e .

Core graph/hypergraph analysis and interactive HTML viewers need no extras. Optional features after publication:

Feature Install
GIF and MP4 export python -m pip install "ciga[visualization]==0.1.5"
Persistent homology python -m pip install "ciga[tda]==0.1.5"
Listener inference with a model provider python -m pip install "ciga[llm]==0.1.5"
Reticula, XGI and Hypergraphx integrations (Python 3.10+) python -m pip install "ciga[hypergraph]==0.1.5"

all includes visualization, TDA and LLM extras; use ciga[all,hypergraph]==0.1.5 for both sets. In a checkout, use python -m pip install -e ".[extra]". See installation for individual backends and pathpyG setup.

Quick start

This complete example counts interactions in each scene and saves an HTML graph:

import pandas as pd
import ciga as cg

dialogue = pd.DataFrame({
    'scene': [1, 1, 2, 2],
    'Speaker': ['Alice', 'Bob', 'Alice', 'Charlie'],
    'Listener': ['Bob', 'Alice', 'Charlie', 'Alice'],
    'text': ['Hello', 'Hi', 'Come in', 'Thanks'],
})
positions = ('scene',)
pairs = cg.prepare_data(dialogue, positions, source='Speaker', target='Listener', interaction='text')
pairs = cg.calculate_weights(pairs, weight_func=lambda text: 1)
tg = cg.TGraph(data=pairs, positions=positions, directed=True)

scores = cg.tgraph_degree_centrality(tg, accumulate=False, weighted=True)
print(scores)  # scene, character, degree columns and weighted degree columns
scores.to_csv('degrees.csv', index=False)

g = tg.get_graph((1,))
cg.graph_viz(g, output_file='scene-1.html', open_browser=False)

Open scene-1.html in a browser. Positions must be numeric, ordered from coarse to fine, for example ('season', 'episode', 'scene', 'line').

Temporal analyses are cumulative by default. Use accumulate=False for separate snapshots or window_size=2 for the last two observed steps, including the current one. Results include time columns, character, and the metric columns.

Choose a representation

Your data or question Use What is retained
Pairwise relationships in one selection igraph.Graph from tg.get_graph(...) and graph_* Edges and their aggregated weights
Pairwise relationships over time TGraph and tgraph_* Time-indexed pair interactions
Participation in group events Hypergraph and hypergraph_* Each event, its participants and metadata
Group events over time THypergraph and thypergraph_* Event identity, directed roles and time

For example, one speaker addressing two listeners remains one hypergraph event:

import pandas as pd
import ciga as cg

dialogue = pd.DataFrame({
    'scene': [1, 1, 2],
    'source': ['Alice', 'Alice', 'Bob'],
    'target': ['Bob, Charlie', 'Bob, Charlie', 'Charlie'],
})
events = cg.prepare_hypergraph_data(dialogue, positions=['scene'])
th = cg.THypergraph(data=events, positions=['scene'])
h = th.get_hypergraph((1,))
assert h.ecount() == 2  # repeated groups remain separate events
print(cg.hypergraph_degree_centrality(h, include_character=True))
cg.hypergraph_viz(h, output_file='groups.html', open_browser=False)

Both temporal classes default to directed. Static centrality tables follow vertex order; temporal centralities add time and character columns. Similar function names do not make graph and hypergraph metrics interchangeable: hypergraph degree counts events, not pairs. See the hypergraph guide and preview migration notes.

Next steps

For annotation or a graphical interface, see CIGA Annotator and CIGA GUI.

Citation and license

If CIGA supports your research, cite it using CITATION.cff, also available under Cite this repository on GitHub:

Hu, S. CIGA: Character Interaction Graph Analysis (Version 0.1.5) [Computer software]. https://github.com/MediaCompLab/ciga

Cite the version used in your analysis. CIGA is licensed under GPL-3.0-or-later.

Metadata

Release files for ciga 0.1.5

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

Source distribution (sdist)

Source distribution for ciga 0.1.5
File Size Uploaded Provenance Actions
ciga-0.1.5.tar.gz 157.2 kB Without provenance Details for ciga-0.1.5.tar.gz

Built distribution (wheel)

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

Total release size: 288.0 kB

Release files / ciga-0.1.5.tar.gz

Download URL ciga-0.1.5.tar.gz
Size 157.2 kB
Tags Source
SHA-256 checksum
How to use checksums
69889216b2441dc6c3a66c52ab37fc78d970547e8beb7bf2c9a61608df7aeedd
BLAKE2b-256 checksum
How to use checksums
1b245be333d8b9c454b21b0c733bcd6fbea1ce51d158ff5ca35a69c2510dbda9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / ciga-0.1.5-py3-none-any.whl

Download URL ciga-0.1.5-py3-none-any.whl
Size 130.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ef2f82a75bed8774da9c1263c82ec1fcd7e87cd8c13a859a38af8567b6bcf02
BLAKE2b-256 checksum
How to use checksums
0f5b65b6ed00a5070e18ed5f9f0955145b5fcaa039fbceac204a7be25f786131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for ciga 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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