Sure! Let's generate a simple dataset for a social network analysis. For simplicity, let's assume we have a small social network of 5 friends. Here's the dataset:
Nodes:
- Alice
- Bob
- Charlie
- David
- Emily
Edges:
- Alice - Bob
- Bob - Charlie
- Charlie - David
- David - Emily
- Emily - Alice
To analyze and visualize this dataset, we'll use Python and the NetworkX library. If you don't have NetworkX installed, you can install it using the command pip install networkx.
Now, let's perform the analysis and visualization:
import networkx as nx
import matplotlib.pyplot as plt
# Create an empty graph
G = nx.Graph()
# Add nodes
nodes = ['Alice', 'Bob', 'Charlie', 'David', 'Emily']
G.add_nodes_from(nodes)
# Add edges
edges = [('Alice', 'Bob'), ('Bob', 'Charlie'), ('Charlie', 'David'), ('David', 'Emily'), ('Emily', 'Alice')]
G.add_edges_from(edges)
# Print basic information about the graph
print("Number of nodes:", G.number_of_nodes())
print("Number of edges:", G.number_of_edges())
# Draw the graph
nx.draw_networkx(G, with_labels=True, node_color='lightblue', node_size=1000, font_size=12, font_weight='bold')
plt.title("Social Network Analysis")
plt.axis('off')
plt.show()
This code will create a graph, add nodes and edges, and then print basic information about the graph (number of nodes and edges). Finally, it will visualize the graph using a networkx function and matplotlib.
The resulting visualization will show the nodes as circles (representing the friends) and the edges as lines connecting them. Each node will be labeled with the friend's name.
I hope this helps you get started with social network analysis using Python! Let me know if you have any further questions.