问题 用于集团发现的Bron-Kerbosch算法


任何人都可以告诉我,在网络上我可以找到Bron-Kerbosch算法的解释,为clique找到或解释它是如何工作的?

我知道它发表在“算法457:找到无向图的所有派系”一书中,但我找不到能描述算法的自由源。

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


11889
2017-09-27 06:44


起源

亚历克斯我打赌这个帖子被低估了“告诉我,在网上哪里......”不要让人们去做你的工作。只要让他们澄清它是如何工作的 - aku
我的意思是在网上,而不是在书中,因为我将无法访问图书馆大约两周:( - Alex Reitbort
而不是要求一个消息来源,更好地说“告诉我如何......有效”,以及对你有什么特别困惑的描述,那么答案(和你的问题的背景)将会出现在将来遇到它的其他人身上。这里接受的答案几乎没用。 - SimonJ


答案:


尝试找一个拥有ACM学生帐户的人,他可以给你一份论文副本,在这里: http://portal.acm.org/citation.cfm?doid=362342.362367

我刚刚下载了它,它只有两页长,在Algol 60中有一个实现!


4
2017-09-27 09:03



你能通过joker99+bron@gmail.com发给我吗? - Alex Reitbort


我在这里找到了算法的解释: http://www.dfki.de/~neumann/ie-seminar/presentations/finding_cliques.pdf 这是一个很好的解释......但我需要一个C#中的库或实现 - .-'


8
2018-03-30 16:38





算法正确 这里 我使用Java链接列表重写它作为集合R,P,X并且它可以工作 喜欢魅力(好的是在根据算法进行设置操作时使用函数“retainAll”)。

由于重写算法时的优化问题,我建议您稍微考虑一下实现


2
2017-10-11 21:20





我还试图围绕Bron-Kerbosch算法,所以我在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)

1
2018-06-25 17:59





为了它的价值,我发现了一个Java实现: http://joelib.cvs.sourceforge.net/joelib/joelib2/src/joelib2/algo/clique/BronKerbosch.java?view=markup

HTH。


0
2017-09-27 11:51



我找到了2个java实现和一个C实现。可能它有用,但我也需要了解它是如何工作的,源代码没有很多关于它是如何工作的评论。 - Alex Reitbort


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

def bron(compsub, _not, candidates, graph, cliques):
    if len(candidates) == 0 and len(_not) == 0:
        cliques.append(tuple(compsub))
        return
    if len(candidates) == 0: return
    sel = candidates[0]
    candidates.remove(sel)
    newCandidates = removeDisconnected(candidates, sel, graph)
    newNot = removeDisconnected(_not, sel, graph)
    compsub.append(sel)
    bron(compsub, newNot, newCandidates, graph, cliques)
    compsub.remove(sel)
    _not.append(sel)
    bron(compsub, _not, candidates, graph, cliques)

然后你调用这个函数:

graph = # 2x2 boolean matrix
cliques = []
bron([], [], graph, cliques)

变量 cliques 将包含发现的派系。

一旦理解了这一点,就可以轻松实现优化的一个。


0
2018-01-28 16:54



甚至算法的版本1也不应检查是否包含一个元素,该元素是候选中每个元素的邻居,如果是这样的话,则回溯? - Andreas Vinter-Hviid


Boost :: Graph具有出色的Bron-Kerbosh算法实现,请给它一个检查。


0
2018-06-17 12:41