<｜begin▁of▁sentence｜>### Instruction:
Given the Political blogs graph which you can read from a GML file named 'polblogs.gml', can you apply the 'surprise_communities' algorithm using cdlib to perform community detection? Additionally, can you convert the results to a JSON format?
### Response:
import networkx as nx
from cdlib import algorithms

# Load the Political blogs graph
G = nx.read_gml('polblogs.gml')

# Apply Surprise Communities algorithm for community detection
communities = algorithms.surprise_communities(G)

# Convert the communities to JSON
communities_json = communities.to_json()

print(communities_json)
<|EOT|>
