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 · 0.1.5 to 0.1.6 migration · Improvement roadmap · Contributing
Install
This documentation targets CIGA 0.1.6 (Python 3.9+). After its PyPI release:
python -m pip install "ciga==0.1.6"
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.6" |
| Persistent homology | python -m pip install "ciga[tda]==0.1.6" |
| Listener inference with a model provider | python -m pip install "ciga[llm]==0.1.6" |
| Reticula, XGI and Hypergraphx integrations (Python 3.12+) | python -m pip install "ciga[hypergraph]==0.1.6" |
all includes visualization, TDA and LLM extras; use ciga[all,hypergraph]==0.1.6
for both sets. In a checkout, use python -m pip install -e ".[extra]".
See installation for individual backends and pathpyG setup.
On Python 3.10/3.11, use ciga[hypergraph-xgi,hypergraph-hgx]==0.1.6 for XGI/HGX.
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 graph analyses default to cumulative for raw interactions and snapshots
for memory states returned by accumulate_weights. Set accumulate=True or False
explicitly, or use window_size=2 for the last two observed steps.
Results include time columns, character, and the metric columns.
Signed pairwise graphs are available in this development checkout: construct a
TGraph with weight_policy='signed', or subtract two temporal graphs with
cg.subtract_tgraphs_by_weight(pos, neg, weight_policy='signed'). Use
w_normalized='max_abs' or 'l1_abs' to preserve signs before weighted degree
analysis. Negative events require the explicit signed policy; the default remains
for nonnegative data. See signed weights for a complete
example, arithmetic rules and algorithm limits. graph_signed_strength and
tgraph_signed_strength decompose current edge signs into positive/negative
magnitudes, net and absolute strength. Signed viewers retain straight edges and
color only numeric labels green/red; bidirectional labels preserve each direction.
This does not add signed hypergraphs or imply an already published package update.
Retain separate raw relation layers with cg.TMultiLayerGraph({'pos': pos, 'neg': neg}),
then use .project({'pos': 1, 'neg': -1}) for a net TGraph or +1 for both layers
to obtain a total. Normalize the resulting snapshots explicitly. Original layers
remain available by name, with copied metadata and initial graphs. Query weighted
analysis limits with cg.analysis_capabilities() or
cg.get_analysis_capability('graph_betweenness_centrality').
See named temporal layers for clock alignment, support,
serialization and capability-table scope.
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 |
| Several raw pairwise relation layers | TMultiLayerGraph, then explicit .project(...) |
Named TGraphs, initial graphs and projection provenance |
| 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
- Data preparation: columns, weights, CSV input and listener inference.
- Analysis: centrality, communities, TDA and time-respecting paths.
- Visualization: local explorers, time labels, GIF and MP4 export.
- Native hypergraph methods: conversions, assumptions and provenance.
- Dialogue CSV example: run
python examples/hypergraph_dialogue.pyfrom the checkout; outputs go tobuild/hypergraph-dialogue-demo. Add--nativefor installed native methods. - Local backend benchmark: measured workloads and limitations.
For annotation or a graphical interface, see CIGA Annotator and CIGA GUI.
Development records
Maintainers and coding agents: start at AGENTS.md and the
project records for the roadmap, verification workflow and
reproducible performance evidence. These records are separate from the user guide in docs/.
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.6) [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.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ciga-0.1.6.tar.gz | 248.8 kB | Without provenance | Details for ciga-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ciga-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for ciga-0.1.6-py3-none-any.whl |
Total release size: 413.4 kB
Release files / ciga-0.1.6.tar.gz
| Download URL | ciga-0.1.6.tar.gz |
|---|---|
| Size | 248.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1379bbd7c44890e415db5eefd6522ca49c2b39071a19d221bc8295d296193dbd
|
|
BLAKE2b-256 checksum How to use checksums |
4aa82128a76a9f2c08113b8c808c4dc41b813b025b28e330765e25b233b0f311
|
| 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.6-py3-none-any.whl
| Download URL | ciga-0.1.6-py3-none-any.whl |
|---|---|
| Size | 164.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa6ee4fafc2a33cf86176687a5d8c51aadc2ee7fe3eb6ef9d63d043433254de4
|
|
BLAKE2b-256 checksum How to use checksums |
542adf35ba63e6ae696da5327cc3f1c560a879e5e6fec65638d44d3f2a0b578e
|
| 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.6
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.