# Using Graph Embedding Techniques in Process-Oriented Case-Based Reasoning
## 4 Neural-Network-Based Semantic Graph Similarity Measure
### Adapted Neural Network Structure
#### 4.2.1 Adapted Embedder
The GNN consists of several trainable components: a component that embeds composite nodes from \(N_{\text{comp}}\), i.e., \(\text{NN}_{\text{comp}}\), a component that embeds atomic nodes from \(N_{\text{atom}}\), i.e., \(\text{NN}_{\text{atom}}\), a component that embeds edges from \(E_{\text{sem}}\), i.e., \(\text{NN}_{\text{edge}}\), a component that performs messagepropagation, i.e., \(\text{NN}_{\text{prop}}\), and a component that aggregates the node information to a single graph representation vector, i.e., \(\text{NN}_{\text{agg}}\). The embedding process is defined as follows:  
\[ \begin{split}& htree_{v}^{(0)}=\text{NN}_{\text{comp}}(enc_{\text{ semType}}(S(v))),\quad\forall v\in N_{\text{comp}}\\ & htree_{v}^{(0)}=\text{NN}_{\text{atom}}([enc_{\text{semType}}(S( v)),enc_{\text{atom}}(S(v))]),\quad\forall v\in N_{\text{atom}}\\ & htree_{v,w}=\text{NN}_{\text{edge}}(enc_{\text{edge}}(v,w)), \quad\forall(v,w)\in E_{\text{sem}}\end{split}  \tag{11}\]  
In the first step (see Equation (11)), all nodes and edges are embedded, which results in the initial embedding vectors \(htree_{v}^{(0)}\) for each node \(v\in N_{\text{atom}}\cup N_{\text{comp}}\) and \(htree_{v,w}\) for each edge \((v,w)\in E_{\text{sem}}\). Thereby, we use the data type and content for embedding nodes from \(N_{\text{atom}}\) and only the data type for embedding nodes from \(N_{\text{comp}}\). Embedding vectors of edges from \(E_{\text{sem}}\) capture the encoded information of the edge representing a child-of or a parent-of relation. The propagation component passes messages between the nodes and updates their state vector accordingly. \[ \begin{split}& ntree_{w,v}=[htree_{v}^{(k)},htree_{w}^{(k)}, htree_{v,w}],\quad\forall(v,w)\in E_{\text{sem}}\\ & htree_{v}^{(k+1)}=\text{NN}_{\text{prop}}\left(\left[htree_{v} ^{(k)},\sum_{(w,v)\in E_{\text{sem}}}mtree_{w,v}\,\right]\right),\quad\forall v \in N_{\text{comp}}\cup N_{\text{atom}}\end{split}  \tag{12}\]  
Equation (12) shows the propagation process, where an updated state vector \(htree_{v}^{(k+1)}\) is computed for each node \(v\in N_{\text{comp}}\cup N_{\text{atom}}\) in each propagation step \(k\leq K_{\text{tree}}\). This specifies the message-passing step of the GNN, where node information is shared across the edges within the graph. We propose to set the maximum number of propagation steps to 5 based on recommendations from the literature [16; 23], i.e., \(K_{\text{tree}}=5\). \[htree_{G}=\text{NN}_{\text{agg}}\left(\sum_{v\in N_{\text{comp}}\cup N_{ \text{atom}}}h_{v}^{(K_{\text{tree}})}\right) \tag{13}\]  
The final step of the GNN is the aggregation of all node vectors to a single embedding vector that represents the embedded information of the semantic description, i.e., \(htree_{G}\). Equation (13) shows the aggregation where the state vectors of all nodes after the final propagation step \(K_{\text{tree}}\) are summed up with a commutative element-wise vector function (e.g., sum, mean, etc.) to a single vector. This vector is eventually passed through the neural network \(\text{NN}_{\text{agg}}\). Please note that the embedding procedure of semantic descriptions in the tree encoding representation is identical for the semantic descriptions of nodes and edges. Thus, the explanations of Equations (11) to (13) hold for nodes as well as edges and \(htree_{G}\) is a representative for \(h_{v}^{\text{sem}}\) and \(h_{v,w}^{\text{sem}}\). Together with the embedded nodes, this completes \(h_{v}^{(0)}\) and \(h_{v,w}\) from Equation (8).