forked from akandykeller/cloudchaser
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprint_graph.py
35 lines (33 loc) · 1.26 KB
/
print_graph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sc_api_calls as scac
def print_graph(G):
for artist in G.nodes():
if artist:
try:
username = scac.id2username(artist)
followings = G.successors(artist)
followers = G.predecessors(artist)
try:
print(
"\t", username + " has " + str(len(followings)) + " followings"
)
print(
"\t",
username
+ " follows "
+ ", ".join([scac.id2username(x) for x in followings]),
)
except TypeError:
print("No followings home!")
try:
print("\t", username + " has " + str(len(followers)) + " followers")
print(
"\t",
username
+ " is followed by "
+ ", ".join([scac.id2username(x) for x in followers]),
)
except TypeError:
print("No followers home!")
print("-" * 40)
except UnicodeError:
print("Artist's username not found")