import networkx as nx

# Create a graph
G = nx.Graph()

# Add nodes
G.add_node(1)
G.add_nodes_from([2, 3])

# Add edges
G.add_edge(1, 2)
G.add_edges_from([(1, 3), (2, 3)])

# Check your graph
print(G.number_of_nodes())  # 3
print(G.number_of_edges())  # 3
print(list(G.nodes))        # [1, 2, 3]
print(list(G.edges))        # [(1, 2), (1, 3), (2, 3)]

# Get neighbors and degree
print(list(G.neighbors(1)))  # [2, 3] - who node 1 is connected to
print(G.degree[1])          # 2 - how many connections node 1 has

# Add attributes to nodes and edges
G.nodes[1]['color'] = 'red'
G.nodes[1]['age'] = 35

G.add_edge(1, 2, weight=4.7)

# Print node and edge attributes
print(f"\nNode 1 attributes: {G.nodes[1]}")
print(f"Edge (1, 2) attributes: {G[1][2]}")