LeetCode 1615: Maximal Network Rank
Avoid converting data structures to string unnecessarily
Just store tuples of values in indegrees instead of strings:
if i == a:
    indegrees[i].append((i, b))
    indegrees[i].append((b, i))

Iterate over the keys in indegrees directly
In this piece of code:
for i in range(n):
    for j in range(n):
        if f'{i}-{j}' or f'{j}-{i}' in indegrees[i]:
            ...

What you are basically saying is: for every possible pair of integers, check if it's in indegrees, and if so, do something with it. That's very inefficient if there only few elements in indegrees. Why not just iterate over the keys of indegrees instead? You can do it with strings, but then you have to parse each key back into two values, if you store tuples instead it becomes really simple:
for i, j in indegrees:
    ...