# On Ontology-Based Tourist Knowledge Representation and Recommendation
## 3 Ontology-Based Tourist Knowledge Representation and Recommendation Method Development
### Tourist Attraction Recommendation
#### 3.4.2 Tourist Attraction Reasoning  
The tourist attraction reasoning was based on Section 2.4., about the analysis of ontological characteristics. The location of travelers is used to find the direct and indirect relations in the tourist attraction reasoning. This process is explained below. The tourist knowledge ontology is transformed into a relation matrix. (\(X_{i}\), \(X_{j}\)) represents the relationship between two tourist attractions. If the value of (\(X_{i}\), \(X_{j}\)) is 1, it means there is a relationship between tourist attractions \(X_{i}\) and \(X_{j}\). If the value of (\(X_{i}\), \(X_{j}\)) is 0, it means there is no relationship between tourist attractions \(X_{i}\) and \(X_{j}\), as shown in Figure 15.  
As can be seen in Figure 15, tourist attraction \(X_{1}\) is set as the location for the traveler. Tourist attraction reasoning was then carried out to see the direct and indirect relations among the attractions. The results of the reasoning are (\(X_{2}\), \(X_{4}\)), (\(X_{2}\), \(X_{4}\)), (\(X_{3}\), \(X_{6}\)), and (\(X_{3}\), \(X_{7}\)), respectively, as shown in Table 3.  
Figure 14: Process of subject matching. Figure 15: Tourist knowledge ontology transformation into a relation matrix. A computer program was used to automatically carry out tourist attraction reasoning, based on the algorithm shown in Algorithm 1. ```
Tourist knowledge ontology transformation into relation matrix [X\({}_{i}\)] [X\({}_{j}\)] Input relation matrix [X\({}_{i}\)] [X\({}_{j}\)]/[X\({}_{i}\) and \(X_{j}\) represent the tourist attraction names of tourist attraction set, \(X_{i}\) = {\(X_{1}\),\(X_{2}\),\(X_{3}\),..., \(X_{i}\)], \(X_{j}\) = {\(X_{1}\),\(X_{2}\),\(X_{3}\),..., \(X_{j}\)}. Input present position (\(L\))/[\(L\)] represents the location of the traveler. create queue(\(Q\))/queue (\(Q\)) is used to save the search results// main()  for\(X_{i}\) = 1 to \(X_{A}\)//The tourist attractions of \(X_{1}\), \(X_{1}\),..., \(X_{A}\) are set as nodes that travelers have not yet visited, \(X_{A}\) //\(X_{A}\) represents the number of tourist attraction sets  visit[\(X_{i}\)] = false;//The node \(X_{i}\) is set as not visited. for-end visit[\(L\)] = true;//The current location of travelers, (\(L\)), is set as visited  for\(X_{i}\) = 1 to \(X_{A}\)// If (visit[\(X_{i}\)])//It searched the not visited node, \(X_{i}\). visit[\(X_{i}\)] = true;//The found node, \(X_{i}\), is set as visited and will not be searched later. enqueue(\(Q\), \(X_{i}\));//The found node, \(X_{i}\), is saved to queue(\(Q\)) if-end if (all visit[\(X_{i}\)])//It represents all the nodes (\(X_{j}\)) has been visited. Traversal (front(\(Q\)))://It requests traversal() function and loads the first information (node) from queue(\(Q\)). if-end for-end } traversal (\(X_{i}\)){  while (tempty(\(Q\)))/it judges if queue is null for\(X_{j}\) = 1 to \(X_{A}\) if (relation matrix [\(X_{i}\)] [\(X_{j}\)] = 1 &&!visit[\(X_{j}\)])//In relation matrix, the value of (\(X_{i}\), \(X_{j}\)) is 1, and noted \(X_{j}\) is not visited. Then, there is a relationship between \(X_{i}\) and \(X_{j}\), and \(X_{j}\) has not been searched by the program. visit[\(X_{j}\)] = true;//The found node \(X_{j}\) is set as visited and will not be searched later. output (\(X_{i}\), \(X_{j}\));//Out put the result node, \(X_{j}\)  traversal(\(X_{i}\))://It requests traversal() function and loads the value of node(\(X_{i}\)) if-end if (all visit[\(X_{j}\)])//If all the nodes (\(X_{j}\)) has been visited. dequeue(\(Q\));//It delete the front node of queue. traversal(front(\(Q\)))://It requests traversal() function and loads the first information (node) from queue. if-end for-end while-end
```  
**Algorithm 1** Algorithm for tourist attraction reasoning.