<｜begin▁of▁sentence｜>### Instruction:
Create a graph using the Barabási–Albert preferential attachment model with 10 nodes, where each new node attaches to 2 existing nodes with high degree, using a seed of 42 for random number generation.
### Response:
import networkx as nx

# Use the Barabási–Albert graph generator
def generate_ba_graph(n, m, seed=None):
    # Generate a graph using Barabási–Albert preferential attachment model
    G = nx.barabasi_albert_graph(n, m, seed)
    return G

# Example usage
n = 10  # Number of nodes
m = 2   # Number of edges to attach from a new node to existing nodes
seed = 42  # Seed for random number generator

# Generate the graph
ba_graph = generate_ba_graph(n, m, seed)

# Draw the graph
nx.draw(ba_graph, with_labels=True, node_color='lightblue', node_size=500, font_size=10, font_weight='bold')
import matplotlib.pyplot as plt
plt.show()
<|EOT|>
