<｜begin▁of▁sentence｜>### Instruction:
As a Petroleum Engineer, you are responsible for ensuring the safety, efficiency, and economic viability of oil and gas operations. In order to achieve this, you may need to visualize the placement of elements within a system. For instance, you might want to visually represent the location of drilling sites in a specific region and analyze their proximity to one another.

Furthermore, you might be interested in using a layout algorithm such as DrL to determine the optimal placement of these drilling sites. Once the algorithm has been applied to a graph representing the geographical locations of the sites, you may want to save the 2D coordinates to a JSON file for further analysis or visualization.

In this scenario, you could use the igraph library, which provides a comprehensive set of tools for analyzing and visualizing graphs. By integrating the graph data representing the locations of drilling sites into igraph, you can employ the DrL layout algorithm to determine the optimal 2D coordinates for each site and store this information in a JSON file for further processing.
### Response:
from igraph import Graph
import json

# Create an example graph
g = Graph.Erdos_Renyi(n=10, m=20)

# Apply the DrL layout algorithm
drl_layout = g.layout_drl()

# Convert the layout to a list of coordinates
layout_coords = drl_layout.coords

# Save the layout coordinates to a JSON file with a custom function
def save_layout_to_json(layout, filename):
    with open(filename, 'w') as f:
        json.dump(layout, f)

# Usage
save_layout_to_json(layout_coords, 'graph_layout.json')
<|EOT|>
