<｜begin▁of▁sentence｜>### Instruction:
Given the High-energy theory collaborations graph, which you can read from a .gml file named hep-th.gml, can you use the principled_clustering function in cdlib with a specified number of three desired communities to perform community detection? Can you also convert the detected community structure to a JSON format and print it out?
### Response:
from cdlib import algorithms
import networkx as nx

# Read the graph from the .gml file
G = nx.read_gml('hep-th.gml')

# Apply the principled clustering community detection algorithm
coms = algorithms.principled_clustering(G, 3)

# Convert the community structure to JSON format
coms_json = coms.to_json()

print(coms_json)
<|EOT|>
