Metadata-Version: 2.1
Name: ciga
Version: 0.0.2
Summary: Character interaction temporal graph analysis
Home-page: https://github.com/MediaCompLab/CharNet
Author: Media Comprehension Lab
Author-email: shu13@gsu.edu
License: GPL-3.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: igraph
Requires-Dist: numpy
Requires-Dist: tqdm
Requires-Dist: matplotlib
Provides-Extra: all
Requires-Dist: plotly ; extra == 'all'
Requires-Dist: gravis ; extra == 'all'
Requires-Dist: pyvis ; extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest (>=7.0) ; extra == 'dev'
Requires-Dist: twine (>=4.0.2) ; extra == 'dev'

[license](https://img.shields.io/github/license/MediaCompLab/CharNet.svg)
![package](https://github.com/MediaCompLab/CharNet/actions/workflows/python-package.yml/badge.svg?event=push)
![publish](https://github.com/MediaCompLab/CharNet/actions/workflows/python-publish.yml/badge.svg)

# CIGA: Character Interaction Graph Analyzer

CharNet is a Python package designed for performing graph analysis on dynamic social networks based on narratives.
It is a reimplementation of CharNet using igraph.

- **Github:** https://github.com/MediaCompLab/CIGA

## Simple example

---

```python
import ciga as cg
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('bigbang_lines_test.csv')


def weight_func(interaction):
    return 1


interactions = cg.prepare_data(df, ('Season', 'Episode', 'Scene', 'Line'),
                               source='Speaker', target='Listener', interaction='Words')
sub_interactions = cg.segment(interactions, start=(1, 1, 1, 1), end=(2, 1, 1, 1))

weights = cg.calculate_weights(sub_interactions, weight_func)
agg_weights = cg.agg_weights(weights, ('Season', 'Episode', 'Scene', 'Line'), agg_func=lambda x: sum(x))

tg = cg.TGraph(data=agg_weights, position=('Season', 'Episode', 'Scene', 'Line'), directed=False)

graph = tg.get_graph()
fig, ax = plt.subplots()
cg.iplot(graph, target=ax)

res = cg.tgraph_degree(tg, weighted=True, normalized=True)

res.to_csv('results.csv')

plt.show()
```

## Install

---

Install the latest version of CharNet:

```bash
$ pip install ciga
```
Install with all optional dependencies:
```bash
$ pip install ciga[all]
```

## To Do
- [x] Add non-directed graph support
- [ ] Add closeness centrality
- [ ] Add Eigenvector centrality
- [ ] Add Louvain community detection
- [ ] Add temporal visualization
- [ ] Add centrality visualizer (with visualization)

## License

Released under the [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html).

```
Copyright (c) 2024 Media Comprehension Lab
```
