swdata/count_neighbors.py
2018-12-04 19:30:33 +08:00

19 lines
466 B
Python

# from G254
import json
from pathlib import Path
from island.match import Match
from island.matches import Matches
count = 0
players = set()
# ms = Matches.from_profile('CCCN')
ms = Matches.from_profile_expr(lambda r: True)
for m in ms.data:
for r in m.query('neighbor', 'create').raw_data:
count += 2
players.add(r['a'])
players.add(r['b'])
print("participants: %d, degree: %d, avg: %f" % (len(players), count, count / len(players)))