EpiK’s knowledge graph: League of Legends

EpiK Protocol
5 min readApr 25, 2024

EpiK Protocol has been dedicated to collecting and organizing more knowledge graphs. EpiK’s label-to-earn mechanism has brought a global community of 120,000 registered users together to curate more practical knowledge graphs.

Today, we are showcasing the knowledge graph of “League of Legends” (LOL) created by the Chinese-speaking community.

1. Graph Project Introduction

“League of Legends” (LOL) is a hero-based MOBA (Multiplayer Online Battle Arena) game developed by Riot Games, a company based in the United States, and operated in mainland China by Tencent Games. It is a globally popular electronic game. The game features hundreds of unique heroes and includes distinctive progression systems such as the ranking and rune systems. As one of the esports events for the 19th Asian Games held in Hangzhou in 2022, “League of Legends” requires more people to understand it.

In the game, “League of Legends,” there are 157 heroes, and players team up with their allies to attack the opposing team. Each hero has different attack abilities, defense capabilities, player difficulty levels, and requires different amounts of in-game currency to purchase. Heroes are also categorized into different factions and roles, and even have family relationships within the rich background story. Therefore, this project focuses on constructing a knowledge graph representing the relationship between heroes and their roles. The entities include heroes and roles, and the relationships include the affiliation of heroes to specific factions and the relationships between heroes (e.g., siblings).

Firstly, we collected the basic data of heroes using a web crawler and preprocessed it to store the data in a structured format. Then, we used custom rules to extract and construct the relationships between hero entities, creating triples for the knowledge graph. We imported the constructed data into a Neo4j graph database using Python, completing the knowledge graph’s construction, storage, and visualization. Additionally, we developed a database-free visualization interface for convenient data previewing. On top of the Neo4j graph database, we implemented a simple intelligent question-answering chatbot.

2. Operation of the Graph Project

- Configuration Requirements: Neo4j database and the corresponding Python dependencies should be installed. Remember the username and password for the Neo4j database and modify the relevant files accordingly.

- Knowledge Graph Data Import: Run the command “python build_herosgraph.py” to import the data into the Neo4j database.

- Start the Question-Answering: Run the command “python chatbot_graph.py” to start the question-answering functionality.

3. Project Results

3.1 Original Dataset

Figure 3–1: Original Dataset

3.2 Customized Visualization Interface

Figure 3–2: Customized Visualization Interface

3.3 Neo4j Visualization Interface

Figure 3–3: Hero-Difficulty Knowledge Graph

Figure 3–4: Hero-Profession Knowledge Graph

4. Implementation Details

4.1 Data Crawling

The data is obtained by writing a Python script that crawls the official website API of “League of Legends” from https://game.gtimg.cn and saves it as a JSON file for easy access in subsequent processes.

The crawling script begins by specifying the target webpage to crawl and then populates the headers variable to indicate the browser to be used for logging in and crawling. The Python `requests` package is then utilized to retrieve the entire hero information JavaScript file, which is subsequently converted into a JSON data file using the `json` function.

The converted JSON file is shown in the following image.

Figure 4–1: Data Crawling

4.2 Customized Visualization Interface

4.2.1 Environment Configuration

The customized visualization interface is primarily a demo showcasing functionality. It is a web-based knowledge graph visualization interface built using the Vue.js front-end framework and the G6 graph visualization engine.

Table 4–1 Environment Configuration Table

4.2.2 Data Loading and Display

Firstly, the canvas is initialized with the mode set to draggable, allowing nodes to be moved. The default layout is set to circular, and default parameters such as node shape, size, and edge settings are specified within the canvas. The specific functionality settings are illustrated in the following image.

Figure 4–2: Data Loading Code

Next, the data is extracted to generate a data graph that corresponds to the relationships between heroes and professions, as well as heroes and difficulty levels. Subsequently, the data graph is utilized to generate nodes, creating nodes of different types based on data segmentation. Finally, connections are established between nodes based on their corresponding relationships. The generated heroes-professions and heroes-difficulty relationships are illustrated in the following image.

Figure 4–3a: Hero-Profession Knowledge Graph

Figure 4–3b: Hero-Difficulty Knowledge Graph

4.3 Knowledge Graph Construction

Neo4j is used for constructing the knowledge graph, along with the Neo4j visualization interface. The overall graph visualization is showcased as follows:

Figure 4–4: Overall Graph Visualization

The construction method is as follows:

(1) Install Java 11 and the community edition of Neo4j graph database, and import the py2neo package.

(2) Initialize the connection with the Neo4j database.

(3) Read the crawled JSON data and parse the entities, attributes, and relationships to be constructed. This includes entity relationships such as heroes and professions/difficulty, and relationships between heroes (e.g., siblings), as well as constructing attribute information for each entity.

(4) Use the “Cypher” language to create corresponding entity nodes and relationship edges in the Neo4j graph database.

Knowledge Graph Entity Types

Table 4–2 Entity Types Table

4.3.2 Knowledge Graph Entity Relationship Types

Table 4–3 Entity Relationship Types Table

4.3.3 Knowledge Graph Property Types

Table 4–4 Property Types Table

--

--