<｜begin▁of▁sentence｜>### Instruction:
Given a set of initial nodes [1, 2, 3, 4], and a list of pairs where each pair needs to be unioned, such as [(1, 2), (3, 4), (1, 3)], how can I use the unionfind_union to understand the connectivity or consolidation of elements within the same subsets after performing unions?
### Response:
import networkx as nx

# Create a UnionFind structure
uf = nx.utils.UnionFind()

# The nodes in our example graph
nodes = [1, 2, 3, 4]

# Add nodes to the UnionFind structure
for node in nodes:
    uf[node]

# Perform unions
uf.union(1, 2)
uf.union(3, 4)
uf.union(1, 3)

# Check if two elements are in the same subset
print('Are 1 and 4 connected?', uf[1] == uf[4])
<|EOT|>
