rank flows evenly *out* from a node

This commit is contained in:
Paul Gauthier 2023-06-01 14:58:15 -07:00
parent 33f649dbbd
commit 746f4ccb56

View file

@ -361,12 +361,12 @@ def call_map():
# distribute the rank from each source node, across all of its out edges # distribute the rank from each source node, across all of its out edges
ranked_definitions = defaultdict(float) ranked_definitions = defaultdict(float)
for dst in G.nodes: for src in G.nodes:
dst_rank = ranked[dst] src_rank = ranked[src]
total_weight = sum(data["weight"] for _src, _dst, data in G.in_edges(dst, data=True)) total_weight = sum(data["weight"] for _src, _dst, data in G.out_edges(src, data=True))
dump(dst, dst_rank, total_weight) dump(src, src_rank, total_weight)
for _src, _dst, data in G.in_edges(dst, data=True): for _src, dst, data in G.out_edges(src, data=True):
data["rank"] = dst_rank * data["weight"] / total_weight data["rank"] = src_rank * data["weight"] / total_weight
ident = data["ident"] ident = data["ident"]
ranked_definitions[(dst, ident)] += data["rank"] ranked_definitions[(dst, ident)] += data["rank"]