On this page:
graph-tree-twigs/  c
graph-tree-branch/  c
graph-tree/  c
graph->tree
statements->tree
tree->statements

10 Module tree🔗ℹ

 (require rdf/core/tree) package: rdf-core

The following diagram demonstrates the structure of a graph tree, rather than representing the graph as a simple set of statements it turns the graph into a map of maps indexed initially by subject, then by predicate, and finally objects are collected into a set per statement-predicate path.

┌─root─┐      ┌─limb─┐     ┌branch┐     ┌──────────twigs────────────┐

              ┌──────┐

          ┌──▶│ sub1 ─▶    ┌──────┐

             └──────┘ ┌──▶│ prd1 ─▶

                         └──────┘     ┌──────────────────────────

┌──────┐     ┌──────┐ │   ┌──────┐     │┌──────┐┌──────┐┌──────┐

│ tree ───┼──▶│ sub2 ──┼──▶│ prd2 ─────▶││ obj1 ││ obj1 ││ obj1 │┈┈

└──────┘     └──────┘ │   └──────┘     │└──────┘└──────┘└──────┘

                         ┌──────┐     └──────────────────────────

             ┌──────┐ └──▶│ sub3 ─▶

          └──▶│ sub3 ─▶    └──────┘

              └──────┘

Tree Module Overview

value

graph-tree-twigs/c : contract?

The twigs of the tree are a set of object? values.

value

graph-tree-branch/c : contract?

This is a mapping from a single predicate? to a graph-tree-twigs/c set.

value

graph-tree/c : contract?

This is a mapping from a single subject? (limb) to a graph-tree-branch/c map.

procedure

(graph->tree graph)  graph-tree/c

  graph : graph?
Returns a graph-tree/c version of the provided graph?.

procedure

(statements->tree statements)  graph-tree/c

  statements : statement-set?
Returns a graph-tree/c version of the provided statement-set?.

procedure

(tree->statements tree)  statement-set?

  tree : graph-tree/c
Returns a statement-set version of the provided graph-tree/c?.