## 4 Methods
### Shrink Algorithm  
The closer the initial community is to the optimal solution, the less efficient the Local Extend algorithm is. In the worst case, it needs to traverse all nodes. In order to solve this query dilemma, we design a Shrink algorithm, which is also inspired by k-core nesting. Given an initial feasible community \(H_{B}\), to obtain a better solution \(H^{\prime}_{B}\subset H_{B}\), then we only need to delete some nodes \(V_{H_{B}-H^{\prime}_{B}}\) from \(H_{B}\). According to the definition of TWC, we can delete nodes that contribute less to the score of the subgraph without damaging the structure of the feasible community. As shown in Algorithm 2, the Shrink algorithm can be divided into three steps. First, we operate core decomposition and find the maximum k-core containing \(q\) as the initial subgraph \(H\) of the algorithm. Then, for each node \(v\) in \(H\), we calculate their similarity score \(TScore(q,v)\) and sort them in ascending order according to the score. Finally, we delete nodes gradually until \(H\) cannot be maintained as a feasible community and take the latest feasible solution as the optimal solution.  
```
Input: A graph \(G=(V,E)\), a query node \(q\), a non-negative integer \(k\). Output: A \(k-core\)\(H_{B}\) with the maximum \(TScore(q,H_{B})\).
1: Find the maximum feasible community \(H\) as initial subgraph.
2: Compute \(TScore(q,v)\), form them as an ascending list \(Sim\_list=\{(v,TScore(q,v)):\forall v\in H\}\).
3: Compute and form their core numbers as \(Core(H)=\{(v,core(v)):\forall v\in H\}\).
4:while\(H\) exists do
5:\(H_{B}\gets H\) ;
6: Select the first node \(v\) in \(Sim\_list\) as the node to be deleted.
7: Delete \(v\) and its incident edges from \(H\);
8: Delete \(v\) from \(Sim\_list\);
9: Update \(Core(H)\) with the core maintenance algorithm, and organize nodes as \(Impossible=\{v:\forall v\in H\) and \(core\ number\ core(v)<k\}\)
10: For nodes in \(Impossible\), remove them from \(H\) and \(Sim\_list\);
11: Maintain \(H\) as a feasible community;
12: Return the latest feasible community as \(H_{B}\).
```  
**Algorithm 2** Shrink Algorithm \((G,q,k)\)  
As shown in Algorithm 2, the Shrink algorithm maintains an ascending sequence of similarity. Deleting nodes one by one according to the order in \(Sim\_list\) can gradually improve the score of feasible community and avoid blind trial and error. We note that deleting nodes may change the core numbers of their neighbors. Therefore, we employ the dynamic core maintenance algorithm proposed by [23] to update the core numbers, avoiding multiple global core decomposition. We record these nodes whose core number is less than \(k\) during the core maintenance procedure and organize them as \(Impossible\). Then, we remove them from \(Sim\_list\), which can significantly shorten the length of \(Sim\_list\) and stop the iteration as early as possible.  
As shown in Figure 1, we initiate the query \(Q=(G,q,3)\), and the initial feasible community is \(H_{1}=\{q,v_{4},v_{2},v_{1},v_{0},v_{5}\}\). According to the Shrink algorithm, we first delete  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Step** & \(Et\) & \(C\) & \(H_{Et+v}\) & \(H_{B}\) \\ \hline Step 1 & \(q\) & \(v_{5},v_{0},v_{1},v_{2},v_{4}\) & \(\varnothing\) & \(q,v_{5},v_{0},v_{1},v_{2},v_{4}\) \\ Step 2 & \(q,v_{5}\) & \(v_{0},v_{1},v_{2},v_{4}\) & \(\varnothing\) & \(q,v_{5},v_{0},v_{1},v_{2},v\(v_{4}\), and then we observe that \(\text{core}(v_{2})=2<k\), meaning \(v_{2}\) will not appear in the final feasible community, so that we can remove \(\{v_{4},v_{2}\}\) from \(Sim\_list\) together. After two iterations, the optimal solution found by the Shrink algorithm is \(H_{2}=\{q,v_{5},v_{0},v_{1}\}\), which is the same as the Local Extend algorithm.