d23p2 use pivoting
This commit is contained in:
@@ -16,13 +16,14 @@ func readInput(_ filePath: String) throws -> Network {
|
||||
func bronkerbosch(
|
||||
_ network: Network, r: Set<String>, p: Set<String>, x: Set<String>
|
||||
) -> Set<String>? {
|
||||
if p.count == 0 && x.count == 0 {
|
||||
return r
|
||||
if p.count == 0 {
|
||||
return x.count == 0 ? r : nil
|
||||
}
|
||||
var maxClique: Set<String>? = nil
|
||||
var nextP = p
|
||||
var nextX = x
|
||||
for v in p {
|
||||
let u = p.union(x).first! // can also choose highest degree node
|
||||
for v in p.subtracting(network[u]!) {
|
||||
if let clique = bronkerbosch(network,
|
||||
r: r.union([v]),
|
||||
p: nextP.intersection(network[v]!),
|
||||
|
Reference in New Issue
Block a user