I have a DataFrame:
df = pd.DataFrame({\'node_a\': [\'X\', \'X\', \'X\', \'Y\', \'Y\', \'Y\', \'Z\', \'Z\', \'Z\'], \'node_b\': [\'X\', \'Y