Beispiel #1
0
def distances(g: Graph):
    dist = shortest_distance(g, directed=g.is_directed())
    return np.array([[y for y in x] for x in dist], dtype=int)
Beispiel #2
0
def components(g: Graph):
    comp, *_ = label_components(g, directed=g.is_directed())
    com = np.zeros(np.max(comp.a) + 1, dtype=int)
    np.add.at(com, comp.a, 1)
    return com