Skip to content

Commit dc77fe3

Browse files
authored
This recipe for smetric is the fastest (#38)
* This recipe for smetric is the fastest * Make flake8 happy
1 parent 725a0b9 commit dc77fe3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: graphblas_algorithms/algorithms/smetric.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from graphblas import binary
2+
13
__all__ = ["s_metric"]
24

35

@@ -6,7 +8,7 @@ def s_metric(G):
68
degrees = G.get_property("total_degrees+")
79
else:
810
degrees = G.get_property("degrees+")
11+
return (binary.first(degrees & G._A) @ degrees).reduce().get(0) / 2
912
# Alternatives
1013
# return (degrees @ binary.second(G._A & degrees)).reduce().get(0) / 2
11-
# return (binary.first(degrees & G._A) @ degrees).reduce().get(0) / 2
12-
return degrees.outer(degrees).new(mask=G._A.S).reduce_scalar().get(0) / 2
14+
# return degrees.outer(degrees).new(mask=G._A.S).reduce_scalar().get(0) / 2

Diff for: setup.cfg

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ exclude =
99
graphblas_algorithms/*/tests/,
1010
graphblas_algorithms/*/*/tests/,
1111
build/
12-
ignore =
13-
E203, # whitespace before ':'
14-
E231, # Multiple spaces around ","
15-
W503, # line break before binary operator
12+
extend-ignore =
13+
E203,
14+
# E203 whitespace before ':' (to be compatible with black)
1615
per-file-ignores =
1716
__init__.py:F401,F403, # allow unused and star imports
1817
test_*.py:F401,F403,

0 commit comments

Comments
 (0)