Ejemplo n.º 1
0
def explore(graph: UndirectedGraph, reporter: Reporter) -> None:
    """Naive Bron-Kerbosch algorithm, optimized"""
    if candidates := graph.connected_vertices():
        visit(graph=graph,
              reporter=reporter,
              candidates=candidates,
              excluded=set(),
              clique=[])
Ejemplo n.º 2
0
def explore(graph: UndirectedGraph, reporter: Reporter) -> None:
    """Bron-Kerbosch algorithm with pivot of highest degree within remaining candidates
       chosen from candidates only (IK_GP)"""
    if candidates := graph.connected_vertices():
        visit(graph=graph,
              reporter=reporter,
              pivot_choice_X=False,
              candidates=candidates,
              excluded=set(),
              clique=[])
Ejemplo n.º 3
0
def test_degeneracy_ordering_nonempty(adjacencies: List[Set[Vertex]]) -> None:
    g = UndirectedGraph(adjacencies=adjacencies)
    connected_vertices = g.connected_vertices()

    ordering = list(degeneracy_ordering(g))
    assert set(ordering) == connected_vertices
    assert all(g.degree(ordering[0]) <= g.degree(v) for v in ordering[1:])

    ordering_min1 = list(degeneracy_ordering(g, drop=1))
    assert ordering_min1 == ordering[:-1]