Skip to content

Commit 472f8bf

Browse files
authored
Merge pull request #35 from saibalmars/fix_karate_weight
Update POT api
2 parents bc98a4e + 9fd7798 commit 472f8bf

File tree

7 files changed

+24
-9
lines changed

7 files changed

+24
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: [3.6, 3.7, 3.8]
21+
python-version: [3.6, 3.7, 3.8, 3.9]
2222
os: [ubuntu-latest, macOS-latest]
2323
include:
2424
- os: ubuntu-latest

GraphRicciCurvature/OllivierRicci.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def _sinkhorn_distance(x, y, d):
247247
248248
"""
249249
t0 = time.time()
250-
m = ot.sinkhorn2(x, y, d, 1e-1, method='sinkhorn')[0]
250+
m = ot.sinkhorn2(x, y, d, 1e-1, method='sinkhorn')
251251
logger.debug(
252252
"%8f secs for Sinkhorn dist. \t#source_nbr: %d, #target_nbr: %d" % (time.time() - t0, len(x), len(y)))
253253

GraphRicciCurvature/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.5.3"
1+
__version__ = "0.5.3.1"
22
__author__ = "Chien-Chun Ni"
33
__email__ = "saibalmars@gmail.com"

notebooks/tutorial.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
"source": [
103103
"### Load sample graph\n",
104104
"\n",
105-
"- First, let's load karate club graph from networkx as an example."
105+
"- First, let's load karate club graph from networkx as an example.\n",
106+
"- Ricci curavture and Ricci flow supported weighted graph, but for simplification, let's start from the unweighted graph first."
106107
]
107108
},
108109
{
@@ -119,7 +120,9 @@
119120
},
120121
"outputs": [],
121122
"source": [
122-
"G = nx.karate_club_graph()"
123+
"G = nx.karate_club_graph()\n",
124+
"for (n1, n2, d) in G.edges(data=True):\n",
125+
" d.clear() # remove edge weight "
123126
]
124127
},
125128
{
@@ -1748,7 +1751,7 @@
17481751
],
17491752
"metadata": {
17501753
"kernelspec": {
1751-
"display_name": "Python 3",
1754+
"display_name": "Python 3 (ipykernel)",
17521755
"language": "python",
17531756
"name": "python3"
17541757
},
@@ -1762,7 +1765,7 @@
17621765
"name": "python",
17631766
"nbconvert_exporter": "python",
17641767
"pygments_lexer": "ipython3",
1765-
"version": "3.7.9"
1768+
"version": "3.9.13"
17661769
}
17671770
},
17681771
"nbformat": 4,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cython
22
numpy
33
scipy>=1.0
44
networkx>=2.0
5-
pot
5+
pot>=0.8.0
66
packaging
77
networkit>=6.1
88
python-louvain

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="GraphRicciCurvature",
11-
version="0.5.3",
11+
version="0.5.3.1",
1212
author="Chien-Chun Ni",
1313
author_email="saibalmars@gmail.com",
1414
description="Compute discrete Ricci curvatures and Ricci flow on NetworkX graphs.",

test/test_OllivierRicci.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
def test_compute_ricci_curvature_edges():
88
G = nx.karate_club_graph()
9+
for (n1, n2, d) in G.edges(data=True):
10+
d.clear() # remove edge weight
911
orc = OllivierRicci(G, method="OTD", alpha=0.5)
1012
output = orc.compute_ricci_curvature_edges([(0, 1)])
1113

@@ -14,6 +16,8 @@ def test_compute_ricci_curvature_edges():
1416

1517
def test_compute_ricci_curvature():
1618
G = nx.karate_club_graph()
19+
for (n1, n2, d) in G.edges(data=True):
20+
d.clear() # remove edge weight
1721
orc = OllivierRicci(G, method="OTD", alpha=0.5)
1822
Gout = orc.compute_ricci_curvature()
1923
rc = list(nx.get_edge_attributes(Gout, "ricciCurvature").values())
@@ -46,6 +50,8 @@ def test_compute_ricci_curvature_directed():
4650

4751
def test_compute_ricci_curvature_ATD():
4852
G = nx.karate_club_graph()
53+
for (n1, n2, d) in G.edges(data=True):
54+
d.clear() # remove edge weight
4955
orc = OllivierRicci(G, alpha=0.5, method="ATD", verbose="INFO")
5056
orc.compute_ricci_curvature()
5157
Gout = orc.compute_ricci_curvature()
@@ -65,6 +71,8 @@ def test_compute_ricci_curvature_ATD():
6571

6672
def test_compute_ricci_flow():
6773
G = nx.karate_club_graph()
74+
for (n1, n2, d) in G.edges(data=True):
75+
d.clear() # remove edge weight
6876
orc = OllivierRicci(G, method="OTD", alpha=0.5)
6977
Gout = orc.compute_ricci_flow(iterations=3)
7078
rf = list(nx.get_edge_attributes(Gout, "weight").values())
@@ -82,6 +90,8 @@ def test_compute_ricci_flow():
8290

8391
def test_ricci_community_all_possible_clusterings():
8492
G = nx.karate_club_graph()
93+
for (n1, n2, d) in G.edges(data=True):
94+
d.clear() # remove edge weight
8595
orc = OllivierRicci(G, exp_power=1, alpha=0.5)
8696
orc.compute_ricci_flow(iterations=40)
8797
cc = orc.ricci_community_all_possible_clusterings()
@@ -117,6 +127,8 @@ def test_ricci_community_all_possible_clusterings():
117127

118128
def test_ricci_community():
119129
G = nx.karate_club_graph()
130+
for (n1, n2, d) in G.edges(data=True):
131+
d.clear() # remove edge weight
120132
orc = OllivierRicci(G, exp_power=1, alpha=0.5)
121133
cut, clustering = orc.ricci_community()
122134
cut_ans = 1.2613588421005884

0 commit comments

Comments
 (0)