# Social Graph

## SocialGraphV2

::: aifastdb.SocialGraphV2

Graph engine for managing persons, relationships, tags, and entities with concurrent sharding and WAL persistence.

### Person CRUD

```python
person = sg.add_person({"name": "Alice", "age": 30})
sg.get_person(person["id"])
sg.update_person(person["id"], {"age": 31})
sg.delete_person(person["id"])
sg.list_persons()
```

### Relationships

```python
sg.add_friend(alice_id, bob_id)
sg.remove_friend(alice_id, bob_id)
sg.get_friends(alice_id)
sg.are_friends(alice_id, bob_id)
```

### Path Finding

```python
path = sg.find_path(alice_id, carol_id, {"max_hops": 3})
all_paths = sg.find_all_paths(alice_id, carol_id, max_hops=4, max_paths=5)
intermediaries = sg.find_intermediaries(alice_id, carol_id)
```

### Network Analysis

```python
mutual = sg.get_mutual_friends(alice_id, bob_id)
strength = sg.calculate_relationship_strength(alice_id, bob_id)
suggestions = sg.suggest_connections(alice_id)
contacts = sg.get_nth_degree_contacts(alice_id, max_degree=3)
stats = sg.get_network_stats(alice_id)
```

### Family Tree

```python
sg.add_parent_child(parent_id, child_id)
sg.add_spouse(person_a, person_b)
ancestors = sg.get_ancestors(person_id, max_generations=5)
descendants = sg.get_descendants(person_id)
```
