<｜begin▁of▁sentence｜>### Instruction:
Given a graph with edges (1, 2), (1, 3), (3, 4), and (4, 2), can you use Graph.degree in networkx to find the degrees of all vertices?
### Response:
import networkx as nx

# Create a new graph
G = nx.Graph()
# Add some edges
G.add_edge(1, 2)
G.add_edge(1, 3)
G.add_edge(3, 4)
G.add_edge(4, 2)

# Get the degree of vertex 1
degree_of_vertex_1 = G.degree(1)
print('Degree of vertex 1:', degree_of_vertex_1)

# Get the degrees for all vertices
all_degrees = G.degree()
print('All degrees:', all_degrees)
<|EOT|>
