As mentioned before, when new students join in Howgarts, Sorting Hat will assign them to four different Houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The Sorting Hat works based on the each student unique characteristic.
In our former work, we generate the Harry Potter network based on WiKi links, We are wondering what if we use community detection to extract the communities form Harry Potter network? Can we get similar result as sorting Hat?
The way we used to detect community is Louvain Algorithm. The Louvain algorithm is a method to extract communities from large networks.
First of all, let’s see the original network which colored by House.
Click on the picture to enlarge the view
Then, let’s use the Louvain Algorithm to detect the community. The community distribution is shown in below.

After execute community detection, we find 9 communities in total, and the modularity with the partition created by the algorithm is 0.29.
In order to compare the network consisted by community, first, we find the four largest communities, Then for the node in these communities, we assigned them different color. For nodes don't belong to these communities, we assigned them grey.
Click on the picture to enlarge the view
From the figure, it is clear to see that the result is different with the original House labels.
- The green community, it seems to be Weasley family, we can see Arthur Wealey, Molly Weasley, Willam Weasly, Ferd Weasly and Geroge Weasly, which belong to green community.
- The blue community, it may be the Harry Potter's close friends. We can see Ronald Weasley and Hermione Granger both belongs to this community.
- There are two main character's in yellow community, Tom Riddle and Albus Dumbledore, and we print the characters in yellow community found most of them are Death Eaters. So maybe this community consist of Tom Riddle and his followers or opponents.
- It is hard for us to find what's the connection between the characters in red community. They from different houses, with different gender. Most of them are teachers, so maybe it's consist of teachers.
- It is surprised that Harry Potter doesn't belongs to top 4 biggest communities.