r"""
Comparing groups: human and machine work
========================================

HyperGodot introduced group tags to overlay hypergraphs. In the
cyber-physical production example every task is tagged ``H`` (human) or
``M`` (machine); line styles distinguish the groups, line widths show the
processing times and vertex sizes the number of tasks of an entity.
"""

# %%
import matplotlib.pyplot as plt

import hatvis as hv
from hatvis.plotting import draw_hypergraph

H = hv.datasets.load_manufacturing_cps()
# [snippet:groups]
print(hv.temporal.group_statistics(H, "group", weight_name="minutes"))
fig, ax = plt.subplots(figsize=(8, 6.5))
draw_hypergraph(H, layout="force", group="group", width_by="weight", size_by="degree", edge_labels=True,
                random_state=3, ax=ax)
# [/snippet:groups]
print("most central entity:", H.degrees().idxmax(), H.degrees().max())
