29 lines
864 B
Python
29 lines
864 B
Python
# see the overview from 2026.07.31
|
|
|
|
sample_graph = {
|
|
'Alice': set(['Bob', 'Carol']),
|
|
'Bob': set(['Alice', 'Dave']),
|
|
'Carol': set(['Alice', 'Eve', 'Mallory']),
|
|
'Dave': set(['Frank', 'Eve', 'Bob']),
|
|
'Eve': set(['Carol', 'Grace', 'Dave']),
|
|
'Frank': set(['Dave', 'Heidi']),
|
|
'Grace': set(['Eve', 'Ivan', 'Mallory']),
|
|
'Heidi': set(['Frank', 'Ivan']),
|
|
'Ivan': set(['Heidi', 'Grace']),
|
|
'Mallory': set(['Carol', 'Grace'])
|
|
}
|
|
|
|
def nth_degree_connections(
|
|
graph: dict[str, set[str]],
|
|
starting_vertex: str,
|
|
max_n: int
|
|
):
|
|
# TODO
|
|
pass
|
|
|
|
print(nth_degree_connections(sample_graph, 'Mallory', 2))
|
|
print(nth_degree_connections(sample_graph, 'Alice', 4))
|
|
print(nth_degree_connections(sample_graph, 'Ivan', 1))
|
|
print(nth_degree_connections(sample_graph, 'Grace', 0))
|
|
print(nth_degree_connections(sample_graph, 'Carol', 100))
|