# How to properly define an edge set with an uncommon condition

I am trying to define an edge set as follows: $$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R \land \text{i and j are not jointly in \mathcal{K}\}}$$, where $$\mathcal{V}$$ is the set of vertices, $$\mathcal{K}$$ is a subset of vertices $$\mathcal{K}\subset\mathcal{V}$$, $$T_{ij}$$ is the travel time between $$i$$ and $$j$$, and $$R$$ is a travel time threshold. So, I would like to create an edge including all edges satisfying the travel time condition and $$i$$ and $$j$$ cannot be both in $$\mathcal{K}$$ at the same time. To better convey, if $$i\in\mathcal{K}$$ and $$j\in\mathcal{K}$$, regardless of the travel time condition ($$T_{ij}\leq R$$), $$(i,j)\notin\mathcal{E}$$. How can I properly write this notation?

While writing the question, I realized the following can be right, can it? $$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\}\setminus\{(i,j)|i,j\in\mathcal{V}\land i,j\in\mathcal{K}\}$$

Yes, that looks correct, although you can simplify a bit because $$\mathcal{K} \subset \mathcal{V}$$: $$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\} \setminus \{(i,j)|i,j\in\mathcal{K}\}$$
Here are two other ways: $$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\land \neg(i\in\mathcal{K} \land j\in\mathcal{K})\}$$ $$\mathcal{E}=\{(i,j)|i,j\in\mathcal{V}\land T_{ij}\leq R\land (i\notin\mathcal{K} \lor j\notin\mathcal{K})\}$$