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?.