Algorithm 团搜索的Bron-Kerbosch算法

Algorithm 团搜索的Bron-Kerbosch算法,algorithm,graph-theory,clique,Algorithm,Graph Theory,Clique,有谁能告诉我,我在网上哪里可以找到布朗克博什集团发现算法的解释,或者在这里解释它是如何工作的 我知道它发表在《算法457:寻找无向图的所有团》一书中,但我找不到描述该算法的免费来源 我不需要算法的源代码,我需要解释它是如何工作的。试着找一个拥有ACM学生帐户的人,他可以给你一份论文的副本,在这里: 我刚刚下载了它,它只有两页长,用Algol 60实现 值得一提的是,我找到了一个Java实现: HTH.有一个正确的算法,我使用Java LinkedList作为集合R、p、X重写了它,它可以工作 就

有谁能告诉我,我在网上哪里可以找到布朗克博什集团发现算法的解释,或者在这里解释它是如何工作的

我知道它发表在《算法457:寻找无向图的所有团》一书中,但我找不到描述该算法的免费来源


我不需要算法的源代码,我需要解释它是如何工作的。

试着找一个拥有ACM学生帐户的人,他可以给你一份论文的副本,在这里:


我刚刚下载了它,它只有两页长,用Algol 60实现

值得一提的是,我找到了一个Java实现:


HTH.

有一个正确的算法,我使用Java LinkedList作为集合R、p、X重写了它,它可以工作 就像一个符咒(好的事情是在根据算法进行设置操作时使用函数“Retainal”)


我建议您考虑一下实现,因为在重写算法时存在优化问题

我在这里找到了对算法的解释:
这是一个很好的解释。。。但是我需要一个C#-.-”中的库或实现

我已经实现了论文中指定的两个版本。我了解到,如果递归求解,则未优化的版本有助于理解算法。 以下是版本1的python实现(未优化):

然后调用这个函数:

graph = # 2x2 boolean matrix
cliques = []
bron([], [], graph, cliques)
变量
派系
将包含找到的派系


一旦您理解了这一点,就很容易实现优化的算法。

Boost::Graph对Bron Kerbosh算法有很好的实现,请检查一下。

我也在尝试了解Bron Kerbosh算法,所以我用python编写了自己的实现。它包括一个测试用例和一些注释。希望这有帮助

class Node(object):

    def __init__(self, name):
        self.name = name
        self.neighbors = []

    def __repr__(self):
        return self.name

A = Node('A')
B = Node('B')
C = Node('C')
D = Node('D')
E = Node('E')

A.neighbors = [B, C]
B.neighbors = [A, C]
C.neighbors = [A, B, D]
D.neighbors = [C, E]
E.neighbors = [D]

all_nodes = [A, B, C, D, E]

def find_cliques(potential_clique=[], remaining_nodes=[], skip_nodes=[], depth=0):

    # To understand the flow better, uncomment this:
    # print (' ' * depth), 'potential_clique:', potential_clique, 'remaining_nodes:', remaining_nodes, 'skip_nodes:', skip_nodes

    if len(remaining_nodes) == 0 and len(skip_nodes) == 0:
        print 'This is a clique:', potential_clique
        return

    for node in remaining_nodes:

        # Try adding the node to the current potential_clique to see if we can make it work.
        new_potential_clique = potential_clique + [node]
        new_remaining_nodes = [n for n in remaining_nodes if n in node.neighbors]
        new_skip_list = [n for n in skip_nodes if n in node.neighbors]
        find_cliques(new_potential_clique, new_remaining_nodes, new_skip_list, depth + 1)

        # We're done considering this node.  If there was a way to form a clique with it, we
        # already discovered its maximal clique in the recursive call above.  So, go ahead
        # and remove it from the list of remaining nodes and add it to the skip list.
        remaining_nodes.remove(node)
        skip_nodes.append(node)

find_cliques(remaining_nodes=all_nodes)

亚历克斯:我敢打赌,那篇帖子被投了“告诉我,网络上的什么地方……”的反对票。不要让别人来做你的工作。只要让他们澄清一下它是如何工作的我的意思是在网络上,而不是在书中,因为我将在大约两周内无法访问图书馆:(与其问来源,不如说“告诉我……是如何工作的”,并说明你特别困惑的是什么,然后回答(以及你问题的上下文)我在这里找到了两个java实现和一个C实现。也许它可以工作,但我也需要了解它是如何工作的,而且源代码中没有太多关于它如何工作的注释。你能在joker99上给我发过来吗+bron@gmail.coms如果不包含候选元素中每个元素的邻居元素,那么算法的版本1难道不应该进行检查吗?如果是这样的话,应该进行回溯吗?
class Node(object):

    def __init__(self, name):
        self.name = name
        self.neighbors = []

    def __repr__(self):
        return self.name

A = Node('A')
B = Node('B')
C = Node('C')
D = Node('D')
E = Node('E')

A.neighbors = [B, C]
B.neighbors = [A, C]
C.neighbors = [A, B, D]
D.neighbors = [C, E]
E.neighbors = [D]

all_nodes = [A, B, C, D, E]

def find_cliques(potential_clique=[], remaining_nodes=[], skip_nodes=[], depth=0):

    # To understand the flow better, uncomment this:
    # print (' ' * depth), 'potential_clique:', potential_clique, 'remaining_nodes:', remaining_nodes, 'skip_nodes:', skip_nodes

    if len(remaining_nodes) == 0 and len(skip_nodes) == 0:
        print 'This is a clique:', potential_clique
        return

    for node in remaining_nodes:

        # Try adding the node to the current potential_clique to see if we can make it work.
        new_potential_clique = potential_clique + [node]
        new_remaining_nodes = [n for n in remaining_nodes if n in node.neighbors]
        new_skip_list = [n for n in skip_nodes if n in node.neighbors]
        find_cliques(new_potential_clique, new_remaining_nodes, new_skip_list, depth + 1)

        # We're done considering this node.  If there was a way to form a clique with it, we
        # already discovered its maximal clique in the recursive call above.  So, go ahead
        # and remove it from the list of remaining nodes and add it to the skip list.
        remaining_nodes.remove(node)
        skip_nodes.append(node)

find_cliques(remaining_nodes=all_nodes)