Orderings Node

john's Avatar

john

04 Jan, 2024 12:38 AM

Today's new node is a node I thought I had made last summer: orderings.

Orderings returns a list of all the possible ways you could arrange n items. Each ordering is a comma-separated list of item indices.

For example, if n = 3, the possible orderings are:

  • 0, 1, 2
  • 0, 2, 1
  • 1, 0, 2
  • 1, 2, 0
  • 2, 0, 1
  • 2, 1, 0

One challenge with this node is that the number of possible orderings grows really fast: n factorial:

  • 3 items have 6 orders
  • 4 items have 24 orders
  • 5 items have 120 orders
  • 6 items have 720 orders
  • 7 items have 5,040 orders
  • 8 items have 40,320 orders

By 8 items, NodeBox starts to puff and pant, so I set an upper limit of 8 for the value of n.

The attached demo and screenshot show one example. I made a subnetwork called "trigram" which makes a shape consisting of a triangle, square, and pentagon glued together. The only difference in the output is in the order in which those three polygons are added: the first goes in the center, the next along its edges, the last as small bumps on the outside. The orderings node supplies the six possible orderings of three items.

The demo also contains a second example which lets you step through all 24 possible orders of four colors. It includes a reorder node that puts any list into a supplied comma-separated order.

I thought I had included this node with the combinatorics toolkit I released last summer, but I did not, so am rectifying that now. It was an interesting challenge making this node in Nodebox.

Comments welcome as always!

  1. Support Staff 1 Posted by john on 04 Jan, 2024 11:49 PM

    john's Avatar

    UPDATE!

    The orderings node I released yesterday is fine. But I noticed an issue with the auxiliary reorder node included in the demo.

    Technically, the reorder node was working correctly. But the way in which it interpreted the input ordering string was counter-intuitive.

    You can see this in the screenshot. The trigrams are in six different orders, but the orders are not arranged in the order you would expect. Looking at the center shape, they are triangle, triangle, square, pentagon, square, pentagon instead of triangle, triangle, square, square, pentagon, pentagon.

    The fourth trigram is in order "1,2,0". Intuitively, you would expect this to mean square in the middle, then pentagon, then triangle bumps. But the reordering node interpreted it to mean triangle in position 1 (middle), square in position 2 (last), pentagon in position 0 (first).

    This is so mind-bending it's hard to talk about. But it matters because anyone typing in an ordering string by hand is likely to assume "1,2,0" means "middle, last, first", not "last, first, middle".

    So I have fixed this. Again, the orderings node is unchanged. But if you want to also use the reorder node, you should use the one included in the revised demo (attached).

    As you can see by the screenshot, the revised reorder node now put the trigrams in the expected order.

    I don't know if anyone is reading this. If you are I apologize. Once I finally release version 3.3 of my library (really, really soon I hope), all updates will be included and we can all forget this mind bending order ordering stuff.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Orderings_Node_Screenshot.png 574 KB
  • orderings_node.ndbx.zip 17.2 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Apr, 2024 07:54 PM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM
16 Apr, 2024 04:23 AM
08 Apr, 2024 01:28 AM

 

07 Apr, 2024 11:50 PM
05 Apr, 2024 11:47 PM
05 Apr, 2024 12:30 AM
25 Mar, 2024 08:48 PM
14 Mar, 2024 07:40 PM
14 Mar, 2024 07:38 PM