Skip to main content Accessibility help
×
Hostname: page-component-84b7d79bbc-7nlkj Total loading time: 0 Render date: 2024-07-30T09:04:00.814Z Has data issue: false hasContentIssue false

30 - Spider spinning for dummies

Published online by Cambridge University Press:  05 March 2013

Richard Bird
Affiliation:
University of Oxford
Get access

Summary

Oh what a tangled web we weave when first we practise to derive.

(With apologies to Sir Walter Scott)

Introduction

Consider the problem of generating all bit strings a1a2 … an of length n satisfying given constraints of the form aiaj for various i and j. The generation is to be in Gray path order, meaning that exactly one bit changes from one bit string to the next. The transition code is a list of integers naming the bit that is to be changed at each step. For example, with n = 3, consider the constraints a1a2 and a3a2. One possible Gray path is 000, 010, 011, 111, 110 with transition code [2, 3, 1, 3] and starting string 000.

The snag is that the problem does not always have a solution. For example, with n = 4 and the constraints a1a2a4 and a1a3a4, the six possible bit strings, namely 0000, 0001, 0011, 0101, 0111 and 1111, cannot be permuted into a Gray path. There are four strings of even weight (the numbers of 1s) and two of odd weight, and in any Gray path the parity of the weights has to alternate.

Constraints of the form aiaj on bit strings of length n can be represented by a digraph with n nodes in which a directed edge ij is associated with a constraint aiaj.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2010

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Spider spinning for dummies
  • Richard Bird, University of Oxford
  • Book: Pearls of Functional Algorithm Design
  • Online publication: 05 March 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511763199.031
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Spider spinning for dummies
  • Richard Bird, University of Oxford
  • Book: Pearls of Functional Algorithm Design
  • Online publication: 05 March 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511763199.031
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Spider spinning for dummies
  • Richard Bird, University of Oxford
  • Book: Pearls of Functional Algorithm Design
  • Online publication: 05 March 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9780511763199.031
Available formats
×