Skip to main content

Character interaction temporal graph analysis

Project description

license package publish

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.

Simple example


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:

$ pip install ciga

Install with all optional dependencies:

$ pip install ciga[all]

To Do

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

Copyright (c) 2024 Media Comprehension Lab

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ciga-0.0.2.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ciga-0.0.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file ciga-0.0.2.tar.gz.

File metadata

  • Download URL: ciga-0.0.2.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for ciga-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ad4aff0d228bfaff5a3bd22478efe8d06274912a5cd0116f690a0ae769043443
MD5 1e405179bb9d2fa99fe316963d0fa777
BLAKE2b-256 7fb969dc6eda816531a3f0901c4e2f832dcf45685064e9f0bc996f8769c32138

See more details on using hashes here.

File details

Details for the file ciga-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ciga-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for ciga-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed86f959dd2f95a88fde258d319470b2bd632cc2ecaf40828e226921ca4477b4
MD5 4104d53b9b241fb9a3a05bd27ea3e9d4
BLAKE2b-256 03c0786121434811177d4cdbbbd951be0231bf4e2f45de60a1c1497de55fda5a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page