def generate_graph(related_subs, subscribers, nsfw_subs, censored, full, min_subscribers, outfile):
""" Make a graphviz graph by adding edges for each sub and related subs """
g = Digraph('G', filename=outfile)
edges_added = 0
for key in related_subs:
for sub in related_subs[key]:
if not sub or not sub in subscribers:
continue
# In nsfw_subs and censored is mutually exclusive
if ((sub in nsfw_subs) != (censored)) or full:
subscriber_cnt = subscribers[sub]
# Filter: only include edge if sub has # subscribers
if subscriber_cnt >= min_subscribers:
g.edge(key, sub, weight=calculate_edge_weight(subscriber_cnt))
print("Edge count: " + str(edges_added))
edges_added += 1
g.save()
评论列表
文章目录