<｜begin▁of▁sentence｜>### Instruction:
If I have a list of edges [(0, 1), (1, 2), (2, 3), (3, 4)], how can I create a NetworkX graph from this edgelist and display its nodes and edges?
### Response:
import networkx as nx
# Define the edgelist
edgelist = [(0, 1), (1, 2), (2, 3), (3, 4)]
# Create the graph using the from_edgelist function
G = nx.from_edgelist(edgelist)
# Now you can use the graph G as usual, for example, print its nodes and edges
print('Nodes:', list(G.nodes()))
print('Edges:', list(G.edges()))
<|EOT|>
