This example demonstrates a complete social network implementation using the GraphModel library, showcasing real-world relationship patterns and graph analytics.
- Building a social network graph structure
- Managing complex relationships (follows, likes, comments)
- Social network analytics and metrics
- Feed generation based on social graph
- Friend recommendation using graph patterns
[Node(Label = "User")]
public record User : Node
{
public string Username { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public DateTime JoinedDate { get; set; }
public string? Bio { get; set; } = string.Empty;
}Posts with tags, timestamps, and author relationships:
[Node(Label = "Post")]
public record Post : Node
{
public DateTime PostedAt { get; set; }
public string Content { get; set; } = string.Empty;
public List<string> Tags { get; set; } = new();
}Multiple relationship types for different interactions:
- FOLLOWS: User following relationships with timestamps
- POSTED: User to post authorship
- LIKES: User likes on posts with timestamps
- COMMENTED_ON: Comments on posts
- WROTE: User authorship of comments
Current implementation demonstrates:
- Follower count analysis
- Post popularity metrics
- Mutual connection discovery
- Engagement tracking
Personalized feed based on who the user follows:
// Get posts from people Alice follows
var aliceFollowing = await graph.Nodes<User>()
.Where(u => u.Username == "alice_wonder")
.PathSegments<User, Follows, User>()
.ToListAsync();
var feedPosts = await graph.Nodes<User>()
.Where(u => followedUserIds.Contains(u.Id))
.PathSegments<User, Posted, Post>()
.ToListAsync();Suggest new connections based on:
- Friends of friends patterns
- Mutual connection count
- Graph traversal algorithms
The example demonstrates common social network patterns:
- Bidirectional relationships (mutual following)
- Content engagement tracking
- Social graph traversal and analytics
- Basic recommendation algorithms
Note: This example requires .NET 10.0 which is not yet released.
cd examples/Example5.SocialNetwork
dotnet runMake sure Neo4j is running and accessible at bolt://localhost:7687 with username neo4j and password password.