<｜begin▁of▁sentence｜>### Instruction:
Given the Astrophysics collaborations graph file named astro-ph.gml, can you perform weighted community detection using the wCommunity function in cdlib, and then generate and print a JSON object representing the detected communities?
### Response:
import networkx as nx
from cdlib import algorithms

# Load the Astrophysics collaborations graph
G = nx.read_gml('astro-ph.gml')

# Set a default weight for all edges (if not already present)
if not nx.get_edge_attributes(G, 'weight'):
    nx.set_edge_attributes(G, values=1, name='weight')

# Perform community detection using the wCommunity algorithm
communities = algorithms.wCommunity(G, min_bel_degree=0.6, threshold_bel_degree=0.6)

# Generate JSON representation of the detected communities
communities_json = communities.to_json()

print(communities_json)
<|EOT|>
