Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

aholanda/charnet

 
 

Repository files navigation

charnet - character networks

This project performed studies using complex networks in some books. We considered characters as nodes and characters encounters as edges. The project has a GitHub page, a manuscript and a presentation.

Directories content

Prerequisites

  • Gnuplot: mixed with jinja2 template engine to produce graphics with excellent quality;
  • Python and the packages:
    • jinja2 - template engine used to handle view tangled with logic;
    • graph-tool - used to calculate the network measures and draw the graphs;
    • numpy and scipy.

Structure

The structure of the project in charnet/ follows, mainly, the Composite design pattern where Book is the Component, Books class is the Composite, and the books like "acts of the apostles" (Acts) and the biography of J. R. R. Tolkien (Tolkien) are Leafs.

UML class diagram

  • Book: methods declared here are inherited by Leaf books, and the main method is read() that returns a Graph containing characters' encounters as edges.

  • Acts: is an example of concrete Leaf classes, like Acts that represents the book "acts of apostles", were coded inside inside the file books.py.

  • Books: is the Composite class, read() method has a different behavior iterating over all Leafs to execute their read() method.

  • Formatting: is responsible to write LaTeX-formatted output to append in the paper.

  • Graphs: process graphs to obtain measures used in the analisys like average degree, betweenness, closeness and lobby.

  • Graph: is a Graph instance from graph-tool library.

  • Plot: plot the curves from data generated from graphs.

  • Draw: draw graphs using graphviz python library.

  • lobby(): function to calculate the lobby index.

  • Charnet: helper to handle configuration specific to books gathered in this project.

  • SGB: helper to handle configuration specific to books gathered in Stanford GraphBase project.

  • Project: template (interface) for project properties.

  • main: client to execute the operations.

Running

Install graph-tool according to your setup by following the installation instructions.

Download the charnet using git and enter in the charnet directory:

$ git clone https://github.com/ajholanda/charnet.git && cd charnet

To install the dependencies, the easy way is to run

$ python3 setup.py install --user

Install graph-tools and run all the project tasks:

$ python3 charnet -a

To print the possible tasks to be performed apart:

$ python3 charnet -h

To clean the generated files:

$ python setup.py clean --all

Feedback

Please, open an issue for any feeback.

Languages

  • Python 64.5%
  • MATLAB 26.5%
  • Gnuplot 4.9%
  • Jinja 4.1%