<｜begin▁of▁sentence｜>### Instruction:
Given the requirement to create a random graph with 20 nodes, where each new node attaches to 3 existing nodes with a preference for nodes with a higher degree, how can one generate such a network using the Barabási–Albert preferential attachment model in NetworkX?
### Response:
import networkx as nx

# Use Barabási–Albert algorithm to generate a graph
B = nx.barabasi_albert_graph(n=20, m=3, seed=42)

print(B.nodes())
print(B.edges())
<|EOT|>
