## Introduction to Network Analysis by Analyzing Characters in Harry Potter Fanfiction by Sara Jakša
## What is Network Analysis
## What is Fanfiction
## Dataset The dataset of all the tags and works on the AO3 fanfiction archive site as of March 2021 Can be found on: https://archiveofourown.org/admin_posts/18804
## Creating a graph import networkx G = networkx.Graph() for node1, node2, weight in edges_list: G.add_edge(node1, node2, weight=weight)

## Some metrics G.nodes() G.edges() len(G_characters.edges())/len(G_characters.nodes()) networkx.density(G) networkx.average_shortest_path_length(G) networkx.diameter(G)

## Connected components networkx.connected_components(G)



## Centrality ### On the example of trope BAMF

## Centrality ### Degree centrality networkx.degree_centrality(G)
* Harry Potter * Hermione Granger * Draco Malfoy * Luna Lovegood * Albus Dumbledore * Sirius Black * Ron Weasley * Severus Snape * Neville Longbottom * Minerva McGonagall
## Centrality ### Betweenes centrality networkx.betweenness_centrality(G, weight='weight')
* Harry Potter (1) * Hermione Granger (2) * Albus Dumbledore (5) * Luna Lovegood (4) * Draco Malfoy (3) * Sirius Black (6) * Severus Snape (8) * Ginny Weasley (15) * Original Characters (23) * Original Female Character(s) (14)
## Centrality ### Page rank networkx.pagerank(G, weight='weight')
* Harry Potter (1 - 1) * Hermione Granger (2 - 2) * Draco Malfoy (3 - 5) * Ron Weasley (7 - 11) * Albus Dumbeldore (5 - 3) * Sirius Black (6 - 6) * Severus Snape (8 - 7) * Remus Lupin (11 - 14) * Luna Lovegood (4 - 4) * Minerva McGonagall (10 - 12)
## Centrality ### Correltions | measure 1 | measure 2 | corr | | --------- | ---------- | ---- | | degree | betweeness | 0.68 | | degree | page rank | 0.89 | | page rank | betweeness | 0.82 |
## How to pick the nodes and edges? ### On the example of tag: "Remus Lupin Needs a Hug"

## Community finding ### On the example of "Alpha/Beta/Omega" from networkx.algorithms import community groups = community.louvain_communities(G)






# Conclusion
# Thank you for listening. Questions? Contact: sarajaksa@sarajaksa.eu or approach me during this conference Presentation is available on https://sarajaksa.eu/content/presentations/2022/pycon-italy-network-analysis