<｜begin▁of▁sentence｜>### Instruction:
Given a directed growing network with redirection (GNR) with 10 nodes and a redirection probability of 0.5, how would you represent the graph as a JSON object with specified details for nodes and edges?
### Response:
import networkx as nx
import json

# Parameters for the GNR graph
n = 10  # number of nodes
p = 0.5  # redirection probability

# Create a GNR graph
D = nx.gnr_graph(n, p, seed=42)
G = D.to_undirected()  # Convert to undirected graph if needed

# Generate JSON object
graph_data = {'graph nodes': [], 'graph edges': []}
for node in G.nodes():
    graph_data['graph nodes'].append({'id': node, 'label': 'Node {}'.format(node)})
for source, target in G.edges():
    graph_data['graph edges'].append({'source': source, 'target': target, 'label': 'Edge from {} to {}'.format(source, target)})

# Convert to JSON string
json_data = json.dumps(graph_data, indent=4)
print(json_data)
<|EOT|>
