## 3 Hierarchical Trajectory Clustering Algorithm
### DBSCAN Algorithm with Automated Parameter Tuning
#### 3.2.3 Sub-Route Clustering  
Through sub-route clustering, general routes and patterns can be identified; this can aid in predicting future ship movements; this enables the detection of whether specific routes are frequently used during certain seasons or times of day and whether certain ship types prefer specific routes. Such insights can be used for predictive modeling and optimizing route planning, supporting strategic decision-making, i.e., making proactive decisions that improve overall ship operation efficiency.  
As a result, the Vessel Traffic Service (VTS) system can more effectively manage ship movements, enhance safety, and reduce the risk of collisions. It can also help identify high-traffic areas and routes prone to congestion, enabling better traffic density predictions. Moreover, by forecasting traffic patterns and adjusting navigational warnings, VTS systems can enhance real-time decision-making.  
In the first DBSCAN clustering analysis, the ship trajectory data were grouped and organized, as shown in Figure 7. To set the criteria for re-performing the DBSCAN clustering analysis based on the distance between the data, the following approach is proposed, which aims to repeatedly perform the DBSCAN clustering analysis based on the criteria presented below and complete the sub-clustering of the ship routes that satisfy the final clustering adoption criteria, thereby proposing an optimal ship route clustering method.  
The criteria are as follows:  
For the 1 st DBSCAN clustering results dataset, where the distance interval between the group data were greater than the average and the size of the distance interval continuously increased or decreased, DBSCAN clustering analysis was performed.  
The process of obtaining the distance interval of the group data are as follows:  
1. From the 1 st DBSCAN clustering results, we grouped the ship trajectories in each cluster from the first to the 50 th data point, as shown in Figure 8.
2. Calculate and normalize the distance between data in a group.  
3. Arrange the calculated distance data in a row. The graph visualizing the groups of sorted data are shown in Figure 9.
4. If the data interval is graphed, it can be represented as shown in Figure 10. If the data interval was larger than the overall average and the interval continuously increased or decreased, a DBSCAN cluster analysis was performed. If the data interval continues to increase, the main route is divided into several routes, and if the data gap continues to decrease, several routes are merged into the main route.  
Second, the area occupied by the grouped data were calculated and compared to the dataset density of the previous clustering result, and the clustering result with the increased density was adopted. The process for calculating the area of the group data are as follows:  
1. Connect the edge data of the group data to obtain the total area, as shown in Figure 11.
2. Calculate the maximum area occupied by one piece of data for the entire area.
3. Find the area occupied by the group data and calculate the ratio to the total area.
4. Calculate the average value of all groups, compare the results of the first cluster, and adopt only the results with increased density.  
Figure 8: Data grouping.  
Figure 7: Sub-route clustering process.  
Figure 10: Data interval graph.  
Figure 9: Graph visualizing distance data.