Imagine your classmates holding hands in a big circle, or like a spider web connecting everyone. That's a graph! It's like a super cool friendship map showing who knows who. Today let's draw this fun map — as easy as playing connect-the-dots!
Graphs: Who's Friends with Who?
A graph is like a big piece of paper with dots (nodes) for kids, connected by lines (edges) for friendships!
Everyday examples:
- Classroom seating: Tom connects to Lily, Lily to Jack
- Subway map: Station A links to B, B to C
- Social media: You follow Mia, Mia follows Sam
Draw a simple graph:
Tom —— Lily
| /
| /
Jack
Tom, Lily, and Jack are all friends!
Two Fun Ways to Play Graphs
1. One-way graphs (like one-way streets):
Tom → Lily → Jack
Tom knows Lily, Lily knows Jack, but Jack might not know Tom back.
2. Two-way graphs (like two-way roads):
Tom ↔ Lily ↔ Jack
Everyone's best buddies both ways!
Super Easy Code to Try (Python)
# Friendship map
friends = {
"Tom": ["Lily", "Jack"], # Tom's friends
"Lily": ["Tom", "Jack"], # Lily's friends
"Jack": ["Tom", "Lily"] # Jack's friends
}
# See Tom's friends
print("Tom's friends:", friends["Tom"]) # ['Lily', 'Jack']
# Find mutual friends
tom_friends = friends["Tom"]
lily_friends = friends["Lily"]
mutual = set(tom_friends) & set(lily_friends)
print("Tom and Lily's mutual friend:", mutual) # {'Jack'}
How to Play the Friendship Map Game?
Get started:
- Open Python (or python.org online)
- Save code as
friendship_map.py - Run:
python friendship_map.pyin command line
What you'll see:
Tom's friends: ['Lily', 'Jack']
Tom and Lily's mutual friend: {'Jack'}
Add your classmates' names and find shared friends!
Graphs Help Everywhere in Life!
- Social apps: "You have 3 mutual friends"
- Map apps: Shortest path (A→B→D is fastest)
- Games: Quickest way to treasure
You're a friendship map master now! Draw your class web or tweak the code to find the "most popular kid." So much fun! 🕸️✨
Top comments (0)