WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Support for embedded subgraphs #20

@chadrik

Description

@chadrik

When thinking about the ability for one graph to load another graph within it (i.e. subgraphs), it seems to me that the storage of such graphs can take 3 forms:

  1. graphs published and consumed as components: often defined as code, and thus not editable within a graph editor UI.
  2. external graph references: graphs saved externally to the parent graph (i.e. a separate "project"). the same graph may be referenced by many other graphs. unlike #1, these are the product of a graph editor (stored as .json or .fbp), rather than code. it may or may not be editable from the parent graph editor, depending on the abilities of the UI
  3. embedded graphs: saved within the parent graph. can only be referenced indirectly by other graphs via its parent. editable from the parent graph editor.

fbp-protocol already supports #1 (in reality it requires no additional support as these subgraphs can simply be treated as components). This ticket is for #3. EDIT: and #2

Below is a bare-bones example of a command sequence that creates a graph within a graph:

protocol: graph
command: clear
payload:
    id: myGraph

---
protocol: graph
command: addnode
payload:
    id: myNode
    graph: myGraph

---
protocol: graph
command: clear
payload:
    id: mySubGraph
    parent: myGraph

---
protocol: graph
command: addnode
payload:
    id: mySubNode
    graph: myGraph/mySubGraph

---
protocol: graph
command: addinport
payload:
    public: IN
    node: mySubNode
    port: IN
    graph: myGraph/mySubGraph

This adds 2 new concepts:

  • sub-graphs may be identified within any graph attribute using /, as in parentGraph/childGraph
  • graph clear gets an optional parent attribute

I chose to add the parent attribute because I wanted this action to be explicit. An alternative would be to use the parent/child notation for the graph clear, like this:

protocol: graph
command: clear
payload:
    id: myGraph/mySubGraph

I'm open to suggestions and opinions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions