Skip to content

Commit 8f1eab9

Browse files
committed
Some cliques changes from james/graphviz
1 parent 363c30b commit 8f1eab9

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

gap/cliques.gi

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ end);
351351

352352
InstallGlobalFunction(DigraphCliquesReps,
353353
function(arg...)
354-
local D, include, exclude, limit, size;
354+
local D, include, exclude, limit, size, group;
355355

356356
if IsEmpty(arg) then
357357
ErrorNoReturn("there must be at least 1 argument,");
@@ -383,8 +383,14 @@ function(arg...)
383383
size := fail;
384384
fi;
385385

386+
if IsBound(arg[6]) then
387+
group := arg[6];
388+
else
389+
group := fail;
390+
fi;
391+
386392
return CliquesFinder
387-
(D, fail, [], limit, include, exclude, false, size, true);
393+
(D, fail, [], limit, include, exclude, false, size, true, group);
388394
end);
389395

390396
# Cliques
@@ -394,7 +400,7 @@ DigraphCliques);
394400

395401
InstallGlobalFunction(DigraphCliques,
396402
function(arg...)
397-
local D, include, exclude, limit, size, out;
403+
local D, include, exclude, limit, size, out, group;
398404

399405
if IsEmpty(arg) then
400406
ErrorNoReturn("there must be at least 1 argument,");
@@ -426,10 +432,16 @@ function(arg...)
426432
size := fail;
427433
fi;
428434

435+
if IsBound(arg[6]) then
436+
group := arg[6];
437+
else
438+
group := fail;
439+
fi;
440+
429441
# use cached value if it's not a special case due to exclusion / size / etc.
430442
if IsList(include) and IsEmpty(include) and IsList(exclude)
431443
and IsEmpty(exclude) and limit = infinity and size = fail
432-
and HasDigraphCliquesAttr(D) then
444+
and HasDigraphCliquesAttr(D) and group = AutomorphismGroup(D) then
433445
return DigraphCliquesAttr(D);
434446
fi;
435447

@@ -441,7 +453,7 @@ function(arg...)
441453
exclude,
442454
false,
443455
size,
444-
false);
456+
group);
445457
# Store the result if appropriate (not special case due to params)
446458
if IsEmpty(include) and IsEmpty(exclude) and limit = infinity and size = fail
447459
and IsImmutableDigraph(D) then
@@ -495,7 +507,8 @@ function(arg...)
495507
return DigraphMaximalCliquesRepsAttr(D);
496508
fi;
497509

498-
out := CliquesFinder(D, fail, [], limit, include, exclude, true, size, true);
510+
out := CliquesFinder(D, fail, [], limit, include, exclude, true, size, true,
511+
fail);
499512
# Store the result if appropriate
500513
if IsEmpty(include) and IsEmpty(exclude) and limit = infinity and size = fail
501514
and IsImmutableDigraph(D) then
@@ -570,14 +583,16 @@ function(arg...)
570583
return MakeImmutable(out);
571584
fi;
572585

573-
return CliquesFinder(D, fail, [], limit, include, exclude, true, size, false);
586+
return CliquesFinder(D, fail, [], limit, include, exclude, true, size, false,
587+
fail);
574588
end);
575589

576590
# A wrapper for DigraphsCliquesFinder
577591
# This is very hacky at the moment, so we could test C code with GAP tests
578592
InstallGlobalFunction(CliquesFinder,
579-
function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
580-
local n, subgraph, group, vertices, include_variant, exclude_variant,
593+
function(digraph, hook, user_param, limit, include, exclude, max, size, reps,
594+
group)
595+
local n, subgraph, vertices, include_variant, exclude_variant,
581596
invariant_include, include_invariant, invariant_exclude,
582597
exclude_invariant, x, v, o, i, out, found_orbits, num_found,
583598
hook_wrapper;
@@ -623,7 +638,10 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
623638

624639
subgraph := DigraphMutableCopyIfMutable(digraph);
625640
subgraph := MaximalSymmetricSubdigraphWithoutLoops(subgraph);
626-
group := AutomorphismGroup(subgraph);
641+
# TODO check that group is a group or fail
642+
if group = fail then
643+
group := AutomorphismGroup(subgraph);
644+
fi;
627645

628646
# Investigate whether <include> and <exclude> are invariant under <group>
629647
vertices := DigraphVertices(digraph);
@@ -683,7 +701,7 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
683701
fi;
684702
fi;
685703

686-
if DigraphNrVertices(digraph) < 512 then
704+
if DigraphNrVertices(digraph) < 2000 then #FIXME
687705
if reps then
688706

689707
if hook = fail then
@@ -702,7 +720,8 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
702720
include,
703721
exclude,
704722
max,
705-
size);
723+
size,
724+
group);
706725
return MakeImmutable(out);
707726
else
708727

@@ -783,7 +802,8 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
783802
include_invariant,
784803
exclude_invariant,
785804
max,
786-
size);
805+
size,
806+
group);
787807

788808
return MakeImmutable(user_param);
789809
fi;
@@ -806,6 +826,8 @@ function(digraph, hook, user_param, limit, include, exclude, max, size, reps)
806826
fi;
807827
end);
808828

829+
# TODO add group as last parameter
830+
809831
InstallGlobalFunction(DIGRAPHS_BronKerbosch,
810832
function(D, hook, param, lim, inc, exc, max, size, reps, inc_var, exc_var)
811833
local vtx, invariant_inc, invariant_exc, invariant, adj, exc_inv, start,

0 commit comments

Comments
 (0)