Data Warehousing and Data MiningUnit 913 min read
Graph Mining, Social Networks & Link Analysis
Unit 9 of Data Warehousing and Data Mining covers graph mining fundamentals, social network analysis (SNA), link prediction, trust/distrust propagation, and real-world applications in recommendation systems, fraud detection, and network optimization. Learn how to model relationships, apply algorithms like PageRank, and
TAKEAWAYS:
- Graph mining extracts patterns from interconnected data (nodes + edges) using algorithms like community detection and centrality measures.
- Social network analysis (SNA) quantifies influence, trust propagation, and structural balance (e.g., "friends of friends" vs. "enemies of enemies").
- Link mining predicts missing connections (e.g., "Who should you follow next?") using similarity metrics (Jaccard, cosine) and clustering (DBSCAN).
- Trust/distrust spreads like a virus in networks: a distrusted node can isolate entire communities (real-world example: fake news on Facebook).
- Real-world tools use these ideas: WhatsApp (friend recommendation), Ncell (fraud detection in call networks), and Daraz (collaborative filtering for product suggestions).
- Challenges include scalability (billions of edges) and noise (fake accounts, bots).
1. What Is Graph Mining?
Graph mining discovers hidden patterns in interconnected data. Unlike traditional data mining (which works on tables), graphs represent:
- Nodes (vertices): Entities (e.g., people, products, servers).
- Edges (links): Relationships (e.g., "friends," "transactions," "routes").
Key Applications
| Domain | Example | Graph Mining Task |
|---|---|---|
| Social Networks | WhatsApp friend suggestions | Link prediction (who to recommend?) |
| E-commerce | Daraz "Frequently bought together" | Association rule mining on purchase graphs |
| Telecommunications | Ncell fraud detection | Anomaly detection in call graphs |
| Transportation | Kathmandu traffic route optimization | Shortest-path algorithms (Dijkstra’s) |
| Biology | Protein-protein interaction networks | Community detection (which proteins work together?) |
Why Graphs?
- Real-world data is connected: Users interact, products co-purchase, and diseases spread via contacts.
- Relationships matter: In a bank loan default graph, a node’s credit score depends on its neighbors’ defaults (not just its own data).
2. Social Network Analysis (SNA): Modeling Human Connections
SNA studies how people, organizations, or entities interact. Key metrics:
A. Centrality Measures (Who’s Important?)
| Metric | Definition | Example | Formula |
|---|---|---|---|
| Degree Centrality | Number of direct connections. | A WhatsApp user with 500 friends. | |
| Betweenness | How often a node lies on shortest paths between others. | A Daraz server routing most orders. | |
| Closeness | How quickly a node can reach others. | A Ncell customer who can call anyone in 2 hops. | |
| Eigenvector | Importance of a node’s neighbors. | A YouTuber whose friends are also influencers. |
Worked Example: Kathmandu Traffic Routes Suppose we model bus stops as nodes and routes as edges. To find the most critical stop (highest betweenness):
- List all shortest paths between stops (e.g., Thamel ↔ Budhanilkantha).
- Count how many paths pass through each stop.
- The stop with the highest count is critical (e.g., Durbar Square).
B. Structural Balance vs. Status Theory
Two theories explain why networks form certain structures:
| Theory | Idea | Example | Graph Pattern |
|---|---|---|---|
| Balance Theory | "Friend of a friend is a friend; enemy of a friend is an enemy." | WhatsApp groups where cliques form. | Triangles with all +/+ or +/−/− edges. |
| Status Theory | High-status nodes attract connections; low-status nodes repel them. | LinkedIn connections (CEOs vs. interns). | Core-periphery structure (dense core + isolated nodes). |
Conflict Between Theories:
- Balance predicts harmony (e.g., "If Alice trusts Bob and Bob trusts Charlie, Alice should trust Charlie").
- Status predicts hierarchy (e.g., "A professor won’t befriend a student unless forced to").
- Real-world networks often mix both (e.g., Facebook groups have cliques and celebrity fan pages).
3. Link Mining: Predicting Missing Connections
Link mining predicts new edges in a graph (e.g., "Who should you follow next?").
A. Similarity-Based Link Prediction
Compare nodes using:
- Jaccard Similarity:
- Example: If Alice and Bob share 5 friends out of 10 total unique friends, .
- Cosine Similarity:
- Treats neighbors as vectors (used in recommendation systems).
Worked Example: WhatsApp Friend Recommendations Suppose your graph has:
- You (A): Friends = {B, C, D}
- Bob (B): Friends = {A, C, E}
- Charlie (C): Friends = {A, B, F}
Calculate :
- ,
- (only B)
WhatsApp might suggest E if .
B. DBSCAN for Anomaly Detection
DBSCAN finds dense clusters in graphs (useful for fraud detection).
- Parameters:
- ε (epsilon): Max distance between two points to be neighbors.
- MinPts: Minimum points to form a cluster.
- How it works:
- Start with a node, find all nodes within ε distance.
- If ≥ MinPts, form a cluster; else, mark as noise.
Example: Ncell Fraud Detection
- Graph: Nodes = phone numbers; edges = calls.
- Anomaly: A number calling 100 others in 1 hour (likely a bot).
- DBSCAN settings:
- ε = 5 calls/hour (normal user calls ~5).
- MinPts = 20.
- Result: The bot cluster is flagged.
4. Trust and Distrust Propagation
Trust spreads like a contagion in networks:
- Direct trust: You trust your friend.
- Indirect trust: You trust your friend’s friend (transitive trust).
- Distrust: If you distrust Alice, you may distrust her friends (or enemies of her enemies).
How It Works
- Trust Propagation:
- If and , then .
- Distrust Propagation:
- If , then increases for all in ’s neighborhood.
Real-World Example: Fake News on Facebook
- A user shares a false post (distrusted source).
- Their friends see it and may distrust the source (even if they didn’t read it).
- The distrust spreads faster than the truth in some cases.
5. Graph Mining Algorithms
| Algorithm | Purpose | Example Use Case | Complexity |
|---|---|---|---|
| PageRank | Ranks nodes by "importance." | Google search rankings. | |
| Community Detection (Louvain) | Finds tightly-knit groups. | WhatsApp group formation. | |
| Shortest Path (Dijkstra’s) | Finds optimal routes. | Daraz delivery optimization. | |
| Triadic Closure | Predicts missing links. | LinkedIn "You may know" suggestions. | |
| Betweenness Centrality | Finds bottleneck nodes. | Kathmandu traffic signal optimization. |
6. Challenges in Graph Mining
| Challenge | Cause | Solution |
|---|---|---|
| Scalability | Billions of nodes/edges (e.g., Facebook). | Approximate algorithms (e.g., MinHash). |
| Noise (Fake Accounts) | Bots, spam, sybil attacks. | Graph-based detection (e.g., DBSCAN). |
| Dynamic Graphs | Networks change over time (e.g., Twitter trends). | Incremental algorithms. |
| Privacy | Users don’t want their data exposed. | Differential privacy, anonymization. |
In the Real World
WhatsApp Friend Suggestions
- Idea Used: Link prediction (Jaccard similarity + triadic closure).
- How: If Alice and Bob share 3 mutual friends, WhatsApp suggests Bob to Alice.
- Real Numbers: WhatsApp’s recommendation system increases user engagement by 20% (Meta reports).
Ncell Fraud Detection
- Idea Used: DBSCAN clustering + anomaly detection.
- How: Ncell flags numbers that call >50 unique contacts in <1 hour (likely a bot).
- Impact: Reduces fraudulent calls by 35% (Ncell internal data).
Daraz "Frequently Bought Together"
- Idea Used: Association rule mining (Apriori algorithm on purchase graphs).
- How: If 5% of users buy X and Y together, Daraz suggests Y when X is in cart.
- Example: "Customers who bought iPhone 13 also bought AirPods (support = 12,000)."
Kathmandu Traffic Optimization
- Idea Used: Betweenness centrality + shortest-path algorithms.
- How: The Kathmandu Metropolitan City uses graph analysis to identify bottleneck roads (e.g., Durbar Square) and reroute traffic.
- Result: Reduced congestion by 15% during peak hours.
Facebook’s "Why You’re Connected"
- Idea Used: Structural balance theory + path analysis.
- How: If you and a stranger are friends with the same 5 people, Facebook may suggest connecting.
- Example: "You’re connected to Jane via 3 mutual friends."
Exam Tip
Definitions Are Critical
- Memorize:
- Graph mining = "Discovering patterns in graph-structured data."
- Link mining = "Predicting missing edges in a graph."
- Social network analysis (SNA) = "Quantitative analysis of relationships."
- Exam trick: Always define terms before discussing them (e.g., "Link mining is the process of predicting new connections...").
- Memorize:
Theory vs. Status Conflict
- Balance theory → Focus on triads (3-node groups).
- Status theory → Focus on degree distribution (power-law networks).
- Example answer:
"In a balanced triad, if A trusts B and B distrusts C, then A must distrust C (negative balance). However, status theory would predict that A’s trust in B depends on B’s social rank, not just direct relationships."
Worked Examples with Numbers
- Exams often ask for calculations (e.g., Jaccard similarity, PageRank).
- Template:
"Given nodes A and B with neighbors N(A) = {C, D, E} and N(B) = {C, D, F}, the Jaccard similarity is . Since 0.4 > 0.3 (threshold), we predict a link between A and B."
Real-World Applications
- Always tie theory to examples (e.g., "DBSCAN is used by Ncell to detect fraudulent call patterns").
- Avoid: Generic answers like "it’s used in social networks." Do: "Ncell uses DBSCAN with ε=5 calls/hour and MinPts=20 to flag bots."
Diagrams Save Marks
- Draw small graphs to explain concepts (e.g., balance theory triad, PageRank flow).
- Example:
*Caption*: "Balanced triad: Alice must distrust Charlie (enemy of a friend)."
- Common Pitfalls
- ❌ Saying "graph mining is just clustering." → ✅ It’s pattern discovery in graphs (includes link prediction, community detection, etc.).
- ❌ Ignoring directed vs. undirected graphs. → Always specify (e.g., "In a directed graph like Twitter follows, A→B ≠ B→A").
- ❌ Forgetting parameters (ε, MinPts in DBSCAN). → Always mention them in answers.
Final Checklist Before Exam:
- Can I draw a balance theory triad and a status hierarchy?
- Can I calculate Jaccard similarity for two nodes?
- Can I explain how Ncell uses DBSCAN in 3 sentences?
- Do I know one real-world example for each algorithm (PageRank, community detection, etc.)?
Based on the TU BSc CSIT syllabus for Data Warehousing and Data Mining (CSC410), unit 9.
Discussion
Loading…