def createChart(): g = Chart(scheme.shape[0]) for index, row in scheme.iterrows(): if list(row[row.apply(lambda x: x == 1)].index): for dest in row[row.apply(lambda x: x == 1)].index: g.addEdge(index, dest) return g