Skip to content

Upgrade networkx to 3.1, igraph/python_igraph to 0.10.4 #35671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/pkgs/igraph/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=igraph-VERSION.tar.gz
sha1=20587332f0f36d6d7eb3cca248e2dab76e1e58ad
md5=af41eb9c614946c4a92a51834e9cab4a
cksum=4011381306
sha1=fc3c6627f889b13581b2b468e1b16aceff453cfc
md5=10a3f325425970c75a7ba8359376e208
cksum=3103730646
upstream_url=https://github.com/igraph/igraph/releases/download/VERSION/igraph-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/igraph/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.2
0.10.4
6 changes: 3 additions & 3 deletions build/pkgs/networkx/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=networkx-VERSION.tar.gz
sha1=40e981041664856ba473c9079006367ed0d0e71b
md5=22139ab5a47818fa00cbaa91eb126381
cksum=4201985987
sha1=d4b1d6117b7c54db61f6cbec8f0ccfb0f7d47293
md5=1a9baa93b7fd4470c80e29a7a6d93ccf
cksum=1675580484
upstream_url=https://pypi.io/packages/source/n/networkx/networkx-VERSION.tar.gz
3 changes: 1 addition & 2 deletions build/pkgs/networkx/install-requires.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# features removed in 3.0 listed in https://networkx.org/documentation/stable/developer/deprecations.html#version-3-0
networkx >=2.4, <3.0
networkx >=2.4, <3.2
2 changes: 1 addition & 1 deletion build/pkgs/networkx/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.8
3.1
6 changes: 3 additions & 3 deletions build/pkgs/python_igraph/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=python-igraph-VERSION.tar.gz
sha1=6a6bca77737ff501e97f808aa18a9045e86b3e3e
md5=6951cc2e803118b74209ae21d54de38a
cksum=650236223
sha1=807a95ad4080d8eb500e7797325d6f11a5c46892
md5=2ac3561dda7e7321789041261a29aba4
cksum=754615899
upstream_url=https://pypi.io/packages/source/i/igraph/igraph-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/python_igraph/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.2
0.10.4
54 changes: 47 additions & 7 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6799,13 +6799,26 @@ def cliques_number_of(self, vertices=None, cliques=None):
{(0, 0): 2, (0, 1): 3, (0, 2): 2, (1, 0): 2, (1, 1): 3, (1, 2): 2}
sage: F.cliques_number_of(vertices=[(0, 1), (1, 2)])
{(0, 1): 3, (1, 2): 2}
sage: F.cliques_number_of(vertices=(0, 1))
3
sage: G = Graph({0:[1,2,3], 1:[2], 3:[0,1]})
sage: G.show(figsize=[2,2])
sage: G.cliques_number_of()
{0: 2, 1: 2, 2: 1, 3: 1}
"""
import networkx
return networkx.number_of_cliques(self.networkx_graph(), vertices, cliques)
if cliques is None:
cliques = self.cliques_maximal()

if vertices in self: # single vertex
return sum(1 for c in cliques if vertices in c)

from collections import Counter
count = Counter()

for c in cliques:
count.update(c)

return {v : count[v] for v in vertices or self}

@doc_index("Clique-related methods")
def cliques_get_max_clique_graph(self):
Expand Down Expand Up @@ -7506,17 +7519,32 @@ def cliques_containing_vertex(self, vertices=None, cliques=None):

sage: C = Graph('DJ{')
sage: C.cliques_containing_vertex()
{0: [[4, 0]], 1: [[4, 1, 2, 3]], 2: [[4, 1, 2, 3]], 3: [[4, 1, 2, 3]], 4: [[4, 0], [4, 1, 2, 3]]}
{0: [[0, 4]],
1: [[1, 2, 3, 4]],
2: [[1, 2, 3, 4]],
3: [[1, 2, 3, 4]],
4: [[0, 4], [1, 2, 3, 4]]}
sage: C.cliques_containing_vertex(4)
[[0, 4], [1, 2, 3, 4]]
sage: C.cliques_containing_vertex([0, 1])
{0: [[0, 4]], 1: [[1, 2, 3, 4]]}
sage: E = C.cliques_maximal()
sage: E
[[0, 4], [1, 2, 3, 4]]
sage: C.cliques_containing_vertex(cliques=E)
{0: [[0, 4]], 1: [[1, 2, 3, 4]], 2: [[1, 2, 3, 4]], 3: [[1, 2, 3, 4]], 4: [[0, 4], [1, 2, 3, 4]]}
{0: [[0, 4]],
1: [[1, 2, 3, 4]],
2: [[1, 2, 3, 4]],
3: [[1, 2, 3, 4]],
4: [[0, 4], [1, 2, 3, 4]]}

sage: G = Graph({0:[1,2,3], 1:[2], 3:[0,1]})
sage: G.show(figsize=[2,2])
sage: G.cliques_containing_vertex()
{0: [[0, 1, 2], [0, 1, 3]], 1: [[0, 1, 2], [0, 1, 3]], 2: [[0, 1, 2]], 3: [[0, 1, 3]]}
{0: [[0, 1, 2], [0, 1, 3]],
1: [[0, 1, 2], [0, 1, 3]],
2: [[0, 1, 2]],
3: [[0, 1, 3]]}

Since each clique of a 2 dimensional grid corresponds to an edge, the
number of cliques in which a vertex is involved equals its degree::
Expand All @@ -7531,8 +7559,20 @@ def cliques_containing_vertex(self, vertices=None, cliques=None):
sage: sorted(sorted(x for x in L) for L in d[(0, 1)])
[[(0, 0), (0, 1)], [(0, 1), (0, 2)], [(0, 1), (1, 1)]]
"""
import networkx
return networkx.cliques_containing_node(self.networkx_graph(), vertices, cliques)
if cliques is None:
cliques = self.cliques_maximal()

if vertices in self: # single vertex
return [c for c in cliques if vertices in c]

from collections import defaultdict
d = defaultdict(list)

for c in cliques:
for v in c:
d[v].append(c)

return {v : d[v] for v in vertices or self}

@doc_index("Clique-related methods")
def clique_complex(self):
Expand Down