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.
_assets
- files used to document or manage the project;charnet
- Python code for the project;data
- data gathered for the project;sgb-data
- some data from Stanford GraphBase.
- 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
andscipy
.
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 Leaf
s.
-
Book
: methods declared here are inherited byLeaf
books, and the main method isread()
that returns aGraph
containing characters' encounters as edges. -
Acts
: is an example of concreteLeaf
classes, likeActs
that represents the book "acts of apostles", were coded inside inside the filebooks.py
. -
Books
: is theComposite
class,read()
method has a different behavior iterating over allLeaf
s to execute theirread()
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 aGraph
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.
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
Please, open an issue for any feeback.