{"id":"af406af0ba782818ccf8eac21dc0d80040693e43f3d2cfca0636ff0fbc99f299","pubkey":"e5272de914bd301755c439b88e6959a43c9d2664831f093c51e9c799a16a102f","created_at":1765745683,"kind":30817,"tags":[["d","graphical-organization-of-decentralized-list-items"],["title","Graphical Organization of Decentralized List Items"],["client","nostrhub.io"]],"content":"Graphical Organization of Decentralized List Items\n=====\n\n`draft`, `optional`\n\nThis NIP augments the [Decentralized Lists NIP](https://nostrhub.io/naddr1qvzqqqrcvypzpef89h53f0fsza2ugwdc3e54nfpun5nxfqclpy79r6w8nxsk5yp0qyt8wumn8ghj7un9d3shjtnswf5k6ctv9ehx2aqqzdjx2cm9de68yctvd9ax2epdd35hxarnwrn9hx) with a mechanism to organize list items using a _directed acyclic graph_.\n\n# Example: Organization of a list of cities\n\nAs an example, we will consider a decentralized list of cities which will be organized by geography and by continent.\n\n![List Items Organized using a DAG](https://i.nostr.build/eOvLzPBZLYEGaHTV.png)\n\nFigure 1: Green circles represent list items (cities). Grey circles represent _sets_ of list items. Grey arrows indicate that one set is a _subset_ of the other. Green arrows indicate that one list item is an _element_ of another set.\n\n# Sets, subsets, and elements\n\nWe require two new Lists: a list of _sets_ and a list of _relationship types_. And we will declare two specific types of relationships: _subset_ and _element_. Note that the list of relationship types and the _subset_ relationship type are used to build hierarchies for other NIPs, such as the [Curated Dual Field Contexts NIP](https://nostrhub.io/naddr1qvzqqqrcvypzpef89h53f0fsza2ugwdc3e54nfpun5nxfqclpy79r6w8nxsk5yp0qy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsqxmrw4exzar9vskkgatpdskkv6t9d3jz6cm0de6x27r5wv63qndn). Once these are declared for one purpose, they can and should be reused: _they do not need to be redeclared_.\n\nIf not already declared by someone else in our community, we declare these lists using kind 9998 events, as per the Decentralized Lists NIP:\n\n```\n{\n  \"kind\": 9998,\n  \"tags\": [\n    [\"names\", \"set\", \"sets\"],\n    [\"description\", \"lorem ipsum\"]\n  ],\n  \"id\": <id_for_list_of_relationship_types>\n}\n```\n\n```\n{\n  \"kind\": 9998,\n  \"tags\": [\n    [\"names\", \"relationship type\", \"relationship types\"],\n    [\"description\", \"lorem ipsum\"],\n    [\"required\", \"direction\"] // directions: forward, reverse, bidirectional, none; specify these details in the description\n  ],\n  \"id\": <id_for_list_of_relationship_types>\n}\n```\n\nThen we create a relationship type called _subset_:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_relationship_types>],\n    [\"name\", \"subset\"],\n    [\"description\", \"lorem ipsum\"],\n    [\"direction\", \"forward\"],\n    [\"required\", \"nodeFrom\"],\n    [\"required\", \"nodeTo\"]\n  ],\n  \"id\": <id_for_subset>\n}\n```\n\nThen we create a relationship type called _element_:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_relationship_types>],\n    [\"name\", \"element\"],\n    [\"description\", \"lorem ipsum\"],\n    [\"direction\", \"forward\"],\n    [\"required\", \"nodeFrom\"],\n    [\"required\", \"nodeTo\"]\n  ],\n  \"id\": <id_for_element>\n}\n```\n\n# Example: \n\nWe will use the tools declared above to organize a list of cities into the hierarchy depicted in the image.\n\nDeclare the list of cities:\n\n```\n{\n  \"kind\": 9998,\n  \"tags\": [\n    [\"names\", \"city\", \"cities\"],\n    [\"description\", \"lorem ipsum\"],\n    [\"required\", \"name\"]\n  ],\n  \"id\": <id_for_list_of_cities>\n}\n```\n\nDeclare Nashville as an item on the list of cities:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_cities>],\n    [\"name\", \"Nashville\"]\n  ],\n  \"id\": <id_for_Nashville>\n}\n```\n\nDeclare the list of sets of cities:\n\n```\n{\n  \"kind\": 9998,\n  \"tags\": [\n    [\"names\", \"set of cities\", \"sets of cities\"],\n    [\"description\", \"lorem ipsum\"],\n    [\"required\", \"name\"]\n  ],\n  \"id\": <id_for_list_of_sets_of_cities>\n}\n```\n\nDeclare one of the sets of the list of cities:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_sets_of_cities>],\n    [\"name\", \"the set of coastal cities\"]\n  ],\n  \"id\": <id_for_the_set_of_coastal_cities>\n}\n```\n\nDeclare a subset relationship between two of the sets:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_relationships>],\n    [\"relationship_type\", <id_for_subset>],\n    [\"nodeFrom\", <id_for_set_of_North_American_cities>],\n    [\"nodeTo\", <id_for_set_of_cities_organized_by_continent>]\n  ]\n}\n```\n\nDeclare Nashville an element of the set of North American cities:\n\n```\n{\n  \"kind\": 9999,\n  \"tags\": [\n    [\"z\", <id_for_list_of_relationships>],\n    [\"relationship_type\", <id_for_element>],\n    [\"nodeFrom\", <id_for_Nashville>],\n    [\"nodeTo\", <id_for_set_of_North_American_cities>]\n  ]\n}\n```","sig":"dd4c0a1e4ab1de47817e62ea1e29b6aee516d04b795a1b985fe50dceeb70056534bf8620040043d069d29c2438114b8c9b2c966f4d0c7ca33d04b652c566d9c2"}