Skip to content

Conversation

@ap4108735
Copy link
Contributor

I have added a function to find the more general notion of a Hamiltonian path, to be used alongside the existing Hamiltonian cycle function. I have also added an associated testing function. At the moment, for large cases the function is not very efficient so I will continue to look into some possible fixes for that.

return true;
end);

InstallMethod(TestHamiltonianPath, "for a digraph", [IsDigraph],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be more consistent with elsewhere in the Digraphs package if it was:

Suggested change
InstallMethod(TestHamiltonianPath, "for a digraph", [IsDigraph],
InstallMethod(IsHamiltonianPath, "for a digraph", [IsDigraph, IsList],

i.e. returns true if the 2nd argument is a hamiltonian path in the 1st argument.

P := HamiltonianPath(D);

if P = fail then
Print("HamiltonianPath returned fail.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an info statement


# 2. Check if path has no repeated vertices
if not IsDuplicateFreeList(P) then
Print("FAIL: Path repeats vertices.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above should be an info statement


# 3. Check if path length equals number of vertices
if Length(P) <> DigraphNrVertices(D) then
Print("FAIL: Path length is ", Length(P),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again

return false;
fi;

Print("SUCCESS: Path is a valid Hamiltonian path.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this should probably be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was committed by accident and should removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove, unless required for something, but I can't see how it could be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

# trivial cases
if v <= 1 then
return DigraphVertices(D);
elif v < 256 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number, comment on reason for choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants