def some_edges_in_all_hamiltonian_cycles
      stack = DS::Stack.new
      result = EdgeSearchResult.new

      # As we are deleting edges, make a deep copy to start with
      g = copy

      # Fill up the stack, in reverse to ease testing
      g.vertices.to_a.reverse.each do |v|
        stack.push v
      end

      while v = stack.pop
        all_neighbours = g.neighbours(v)
        ham_neighbours = result.hamiltonian_neighbours(v)
#        p v
#        p all_neighbours
#        p ham_neighbours

        # If a vertex contains 1 or 0 total neighbours, then the graph cannot contain
        # any hamcycles (in contrast, degree 1 doesn't preclude hampaths).
        if all_neighbours.length < 2
          result.contains_hamcycle = false

        elsif all_neighbours.length == 2
          # If a vertex has degree 2 then both edges must be a part of the hamcycle
          all_neighbours.each do |n|
            unless result.edges_in_all.edge?(v,n)
              result.edges_in_all.add_edge(v,n)
              stack.push n #now need to re-evalute the neighbour, as its neighbourhood is changed
            end

            # if an edge be and must not be in all hamcycles, then the graph is not Hamiltonian.
            # Are there any concrete examples of this? Possibly.
            if result.edges_in_all[v].include?(n) and result.edges_in_none[v].include?(n)
              result.contains_hamcycle = false
            end
          end

        elsif ham_neighbours.length >= 2
          # There cannot be any further hamcycle edges from this vertex, so the rest of the edges
          # cannot be a part of _any_ hamcycle
          all_neighbours.each do |n|
            next if ham_neighbours.include?(n)

            result.edges_in_none.add_edge(v,n)
            g.delete_edge(v,n)
            stack.push n #reconsider the neighbour
          end

        else
          # Anything else that can be done cheaply?
          # Maybe edges that create non-Hamiltonian cycles when only considering edges
          # that are in all Hamiltonian cycles -> these cannot be in any hamcycle

        end
        #p stack
      end
      #p result

      return result
    end
def some_edges_in_all_hamiltonian_cycles
      stack = DS::Stack.new
      result = EdgeSearchResult.new

      # As we are deleting edges, make a deep copy to start with
      g = copy

      # Fill up the stack, in reverse to ease testing
      g.vertices.to_a.reverse.each do |v|
        stack.push v
      end

      while v = stack.pop
        all_neighbours = g.neighbours(v)
        ham_neighbours = result.hamiltonian_neighbours(v)
#        p v
#        p all_neighbours
#        p ham_neighbours

        # If a vertex contains 1 or 0 total neighbours, then the graph cannot contain
        # any hamcycles (in contrast, degree 1 doesn't preclude hampaths).
        if all_neighbours.length < 2
          result.contains_hamcycle = false

        elsif all_neighbours.length == 2
          # If a vertex has degree 2 then both edges must be a part of the hamcycle
          all_neighbours.each do |n|
            unless result.edges_in_all.edge?(v,n)
              result.edges_in_all.add_edge(v,n)
              stack.push n #now need to re-evalute the neighbour, as its neighbourhood is changed
            end

            # if an edge be and must not be in all hamcycles, then the graph is not Hamiltonian.
            # Are there any concrete examples of this? Possibly.
            if result.edges_in_all[v].include?(n) and result.edges_in_none[v].include?(n)
              result.contains_hamcycle = false
            end
          end

        elsif ham_neighbours.length >= 2
          # There cannot be any further hamcycle edges from this vertex, so the rest of the edges
          # cannot be a part of _any_ hamcycle
          all_neighbours.each do |n|
            next if ham_neighbours.include?(n)

            result.edges_in_none.add_edge(v,n)
            g.delete_edge(v,n)
            stack.push n #reconsider the neighbour
          end

        else
          # Anything else that can be done cheaply?
          # Maybe edges that create non-Hamiltonian cycles when only considering edges
          # that are in all Hamiltonian cycles -> these cannot be in any hamcycle

        end
        #p stack
      end
      #p result

      return result
    end
If #edges_in_all_hamiltonian_cycles is too slow, the method
 here is faster, but is not guaranteed to find every edge that is
 part of Hamiltonian cycles. This method proceeds under the assumption
 that the graph has at least 1 Hamiltonian cycle, but may stumble
 across evidence to the contrary.

 Returns an instance of EdgeSearchResult where #edges_in_all are those
 edges that are in all hamiltonian cycles, and #edges_in_none are those
 edges that are not in any hamiltonian cycles. While