Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Created March 28, 2014 01:12
Show Gist options
  • Select an option

  • Save vermiculus/9822949 to your computer and use it in GitHub Desktop.

Select an option

Save vermiculus/9822949 to your computer and use it in GitHub Desktop.
Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('ind-set.ssax/bundle.yaml') as f:
... print("".join(f.readlines()))
...
#%BUNDLE 1.0
- predicate: node should unmark
description: Returns true if the node is marked when a neighbor is also marked.
author: Sean Allred
date: 2014-05-17
tex: "'marked'(n) = 1 `land `exists v `in N(n) : 'marked'(n) = 1"
file: marked-and-neighbor-marked.py
- predicate: node should mark
description: Returns True is the node is unmarked when none of its neighbors are marked.
author: Sean Allred
date: 2014-05-17
tex: "'marked'(n) = 0 `land `forall v `in N(n) : 'marked'(n) = 0"
file: unmarked-and-neighbors-unmarked.py
- move: mark node
description: mark this node
author: Sean Allred
date: 2014-05-17
tex: "'marked'(n) = 1"
file: mark.py
- move: unmark node
description: unmark this node
author: Sean Allred
date: 2014-05-17
tex: "'marked'(n) = 0"
file: unmark.py
- algorithm: Independent Set
author: Sean Allred
date: 2014-05-17
rules:
- description: if a neighbor is marked, unmark
author: Sean Allred
date: 2014-05-17
predicate: node should unmark
moves:
- unmark node
- description: if no neighbors are marked, mark
author: Sean Allred
date: 2014-05-17
predicate: node should mark
moves:
- mark node
>>> bundle = Bundle('ind-set.ssax')
>>> bundle.read()
>>> bundle.algorithms
[<__main__.Algorithm instance at 0x106bdc998>]
>>> bundle.algorithms[0].ruleset
{<function node_should_unmark at 0x106bf9758>: [<function unmark_node at 0x106bf98c0>], <function node_should_mark at 0x106bf97d0>: [<function mark_node at 0x106bf9848>]}
>>> node_should_unmark.__dict__
{'tex': "'marked'(n) = 1 `land `exists v `in N(n) : 'marked'(n) = 1", 'predicate': 'node should unmark', 'description': 'Returns true if the node is marked when a neighbor is also marked.', 'file': 'marked-and-neighbor-marked.py', 'author': 'Sean Allred', 'date': datetime.date(2014, 5, 17)}
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment