【发布时间】:2016-03-20 15:24:05
【问题描述】:
我正在尝试实现 Bron-Kerbosch 算法来查找最大团的数量(最大团是图的子集,其中每两个顶点都连接并且没有更大的团包含它)
https://en.wikipedia.org/wiki/Bron%E2%80%93Kerbosch_algorithm
不幸的是,我收到一个错误:“输入 'res' 上的解析错误” 我似乎无法解决它。我试图用普通的水龙头空间来改变它,但它似乎不起作用。我也没有看到任何错误?有什么想法吗?
type Clique = [Vertex]
swarming::Clique->[Vertex]->[Vertex]->[Clique]
swarming R P X =
if null P && null X then [R]
else loop R X
where
loop::[Vertex]->[Vertex]->[Clique]
loop[] _ =[]
loop(v:R') X=
swarming (v:R)(P 'res' v)(X 'res' v)
loop P (v:X)
type Vertex = Int
class Graph g where
size ::g->Int
verticies ::g->[Vertex]
connected ::g->Vertex->Vertex->Bool
bron::Graph g=>g->[Clique]
bron g = swarming[] (verticies g) []
where
swarming R P X =
if null P && null X then [R]
else loop R X
where
loop::[Vertex]->[Vertex]->[Clique]
loop[] _ =[]
loop(v:R) X=
swarming (v:R)(P 'res' v)(X 'res' v)
loop P (v:X)
res::[Vertex]->Vertex->[Vertex]
res vs v = filter(connected g v) vs
【问题讨论】:
-
我相信你需要使用反引号而不是单引号作为中缀表示法。
P 'res' v对我来说似乎不是有效的 Haskell。