Skip to content

Commit 4887215

Browse files
committed
reset apsp for each Ricci flow computation
1 parent 9b8a57f commit 4887215

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

GraphRicciCurvature/OllivierRicci.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ def _get_all_pairs_shortest_path():
202202
"""Pre-compute all pairs shortest paths of the assigned graph `_Gk`."""
203203
logger.info("Start to compute all pair shortest path.")
204204

205+
global _Gk
206+
205207
t0 = time.time()
206208
apsp = nk.distance.APSP(_Gk).run().getDistances()
207209
logger.info("%8f secs for all pair by NetworKit." % (time.time() - t0))
@@ -572,6 +574,8 @@ def _compute_ricci_flow(G: nx.Graph, weight="weight",
572574
# Set normalized weight to be the number of edges.
573575
normalized_weight = float(G.number_of_edges())
574576

577+
global _apsp
578+
575579
# Start compute edge Ricci flow
576580
t0 = time.time()
577581

@@ -583,6 +587,10 @@ def _compute_ricci_flow(G: nx.Graph, weight="weight",
583587
for (v1, v2) in G.edges():
584588
G[v1][v2]["original_RC"] = G[v1][v2]["ricciCurvature"]
585589

590+
# clear the APSP since the graph have changed.
591+
_apsp = {}
592+
593+
586594
# Start the Ricci flow process
587595
for i in range(iterations):
588596
for (v1, v2) in G.edges():
@@ -616,10 +624,9 @@ def _compute_ricci_flow(G: nx.Graph, weight="weight",
616624
normalized_weight = float(G.number_of_edges())
617625

618626
for n1, n2 in G.edges():
619-
logger.debug(n1, n2, G[n1][n2])
627+
logger.debug("%s %s %s" % (n1, n2, G[n1][n2]))
620628

621629
# clear the APSP since the graph have changed.
622-
global _apsp
623630
_apsp = {}
624631

625632
logger.info("\n%8f secs for Ricci flow computation." % (time.time() - t0))

0 commit comments

Comments
 (0)