# project_bilibili_comments **Repository Path**: gaoruolin/project_bilibili_comments ## Basic Information - **Project Name**: project_bilibili_comments - **Description**: A Python implementation of Bilibili’s multi-level comment tree based on N-ary tree, DFS and heap algorithms. Simulate Bilibili nested comment system using tree traversal, recursion and top-K ranking. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-08 - **Last Updated**: 2026-06-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python ## README # Project — Bilibili Comment Tree ## Introduction This project simulates the multi-level comment & reply tree system used under Bilibili videos. It applies N-ary tree, recursion, DFS traversal and heap data structure to implement data loading, tree construction, node operation, top ranking and optional knockout tournament. The project is divided into 3 core modules and 1 optional bonus module. All business logic is split into separate files for decoupling. The entry file only imports and invokes functions to keep code clean. ## Features - 1.Load original comment data from JSON file - 2.Build N-ary comment tree and print tree structure - 3.Explore the tree: count total replies, find the deepest reply thread, delete specified comment and its sub-replies - 4.Generate leaderboard of top liked comments with heap algorithm - 5.Build knockout tournament bracket for top 8 comments and simulate matches ## Tech Stack - Language: Python 3 - Data Structures: N-ary Tree, Heap, Binary Tree (bonus) - Algorithms: Recursion, Depth-First Search (DFS), Tree -Traversal, Top-K Algorithm - Data Parsing: JSON ## Project structure ``` project_bilibili_comments/ ├── README.md # Project documentation ├── data/ │ └── comments.json # Dataset with about 25 raw comments ├── src/ # Source code directory │ ├── comment.py # M1: Comment class, tree build, display, find by ID │ ├── explorer.py # M2: Count replies, find deepest thread, delete comment │ ├── leaderboard.py # M3: Collect comments, top-K ranking, print leaderboard │ └── tournament.py # M4 (Bonus): Match logic & tournament bracket └── main.py # Main entry: import and orchestrate all functions ``` --- ## Summary This is a comprehensive and practical data structure project centered on tree operations, recursion mechanisms, traversal algorithms and heap sorting logic. It perfectly combines classic computer science data structure knowledge with real-world internet application scenarios, taking Bilibili’s nested multi-level comment system as the core simulation object. Throughout the modularized project development, it covers the full process of structured data parsing, custom N-ary tree construction, recursive tree traversal, tree node query and deletion, and heap-based Top-K sorting. In addition, the optional tournament module further expands the application of binary tree and matching algorithms. By implementing complete business functions including comment data loading, tree structure visualization, comment statistics analysis, hot comment ranking and tournament simulation, this project helps developers deeply consolidate core algorithm and data structure knowledge. Meanwhile, it cultivates standardized modular programming thinking, decoupled code design ideas and practical problem-solving abilities for real business scenarios, laying a solid foundation for more complex front-end and back-end interactive data structure development.