<｜begin▁of▁sentence｜>### Instruction:
Given a time series [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3], convert it into a visibility graph using NetworkX and provide a JSON representation of the graph, including nodes and edges with labels.
### Response:
import networkx as nx
# Example time series
series = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]
# Create the visibility graph from the time series
G = nx.visibility_graph(series)
# Generate JSON object to describe the graph
graph_nodes = [{'id': n, 'label': f'Node {n}'} for n in G.nodes()]
graph_edges = [{'source': u, 'target': v, 'label': f'Edge from {u} to {v}'} for u, v in G.edges()]
graph_json = {'graph nodes': graph_nodes, 'graph edges': graph_edges}
print(graph_json)
<|EOT|>
