<｜begin▁of▁sentence｜>### Instruction:
Using the NetworkX function random_tournament, how can you generate a random tournament graph with a set number of nodes (for example, 5 nodes) and then create and print a JSON representation of that graph, which includes the 'id' and 'label' for each node, as well as the 'source', 'target', and 'label' for each edge?
### Response:
import networkx as nx
import random

# Seed for reproducibility
seed = 42
random.seed(seed)

# Number of nodes
n = 5

# Generate a random tournament graph
G = nx.random_tournament(n, seed=seed)

# Get the nodes and edges from the graph
nodes = [{'id': node, 'label': str(node)} for node in G.nodes()]
edges = [{'source': u, 'target': v, 'label': str(u) + ' -> ' + str(v)} for u, v in G.edges()]

# Convert to JSON
graph_data = {'graph nodes': nodes, 'graph edges': edges}
print(graph_data)
<|EOT|>
