# Graph View

> How Graph View draws a file: one node per resource, with its types, values, lists, blocks and property shapes drawn inside it.

Source: https://semvia.io/docs/authoring/graph-view

Graph View draws an [RDF](https://www.w3.org/TR/rdf11-concepts/) file as nodes and edges. Agents write a lot of RDF quickly, and a picture is taken in faster than text, so Graph View is what you look at to see what an agent read and wrote. It draws one node for each named resource, with the values, lists and blocks that resource holds drawn inside it.

## One file, two drawings

`fleet.ttl` describes one solar installation in [Turtle](https://www.w3.org/TR/turtle/): its type, name and capacity, the company that operates it, the capacity of each construction phase as a list, and its point of interconnection as a block. The terms it uses are declared in `plants.ttl`, a domain model in the same workspace.

Drawn with a node for every resource and for every value the file writes, and an edge for every statement, the file is 16 nodes and 15 edges, three of the nodes blank.

Figure: A ball-and-stick diagram of fleet.ttl. :desert-ridge sits in the middle with six edges: rdf:type to plants:SolarInstallation, plants:name to the literal Desert Ridge Solar, plants:capacityMW to 240.0, plants:operator to :helios-energy, plants:phaseCapacitiesMW to a blank node, and plants:pointOfInterconnection to another blank node. :helios-energy has an rdf:type edge to plants:Company and an rdfs:label edge to Helios Energy. The list's blank node has rdf:first to 120.0 and rdf:rest to a second blank node, which has rdf:first to 120.0 and rdf:rest to rdf:nil. The block's blank node has rdf:type to plants:GridConnection, plants:substation to Palo Verde and plants:voltageKV to 230.

fleet.ttl with a node per resource and per written value, and an edge per statement.

Graph View draws the same file as one node.

Graph

Figure: One node in Folio's Graph View, desert-ridge, with its address and a Solar installation badge. It lists capacityMW 240, name Desert Ridge Solar and operator Helios Energy, then a POINTOFINTERCONNECTION group with substation Palo Verde and voltageKV 230, then a PHASECAPACITIESMW group with rows 1 and 2, each 120.

fleet.ttl in Graph View: one node for desert-ridge, with Helios Energy shown by its label in the operator row.

Turtle

```turtle
@prefix plants: <https://example.org/my-semantic-package/plants#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <https://example.org/my-semantic-package/fleet#> .

# Desert Ridge, a 240-megawatt solar installation built in two phases.
# Helios Energy runs it, and it feeds the grid at the Palo Verde substation.
:desert-ridge a plants:SolarInstallation ;
  plants:name "Desert Ridge Solar" ;
  plants:capacityMW 240.0 ;
  plants:operator :helios-energy ;
  plants:phaseCapacitiesMW ( 120.0 120.0 ) ;
  plants:pointOfInterconnection [
    a plants:GridConnection ;
    plants:substation "Palo Verde" ;
    plants:voltageKV 230
  ] .

# Helios Energy, the company that operates Desert Ridge.
:helios-energy a plants:Company ;
  rdfs:label "Helios Energy" .
```

## Inside a node

Graph View draws each of the six parts below inside a node rather than as nodes and edges of its own. It does this for every file.

### Types

A type, written `a`, draws as a badge under the node's name, showing the class's `rdfs:label`, rather than as an edge to the class.

Figure: The top of the desert-ridge node: its name, its address https://example.org/…/fleet#desert-ridge, and a green Solar installation badge.

a plants:SolarInstallation, drawn as the Solar installation badge.

### Values

A [literal](https://www.w3.org/TR/turtle/#literals), such as a name, a number or a date, draws as a row on its subject's node.

Figure: Two rows on the desert-ridge node: capacityMW 240 and name Desert Ridge Solar.

The capacity and the name, drawn as two rows.

### Resources with only values

A named resource whose only statements are its types and values draws as a link in the row that refers to it, showing its `rdfs:label`.

Figure: The operator row on the desert-ridge node, reading Helios Energy in green.

:helios-energy, drawn as Helios Energy in the operator row.

### Blocks

A [`[ … ]` block](https://www.w3.org/TR/turtle/#unlabeled-bnodes) draws as a group inside the node that holds it, headed by the property that holds it.

Figure: A group headed POINTOFINTERCONNECTION on the desert-ridge node, with the rows substation Palo Verde and voltageKV 230.

The point of interconnection block, drawn as a group of its two values.

### Lists

A [list](https://www.w3.org/TR/turtle/#collections), written `( … )`, draws as a group of numbered rows, one for each item, in order.

Figure: A group headed PHASECAPACITIESMW at the bottom of the desert-ridge node, with row 1 reading 120 and row 2 reading 120.

The phase capacities, drawn as rows 1 and 2.

### Property shapes

In Folio, a class is represented using [RDFS](https://www.w3.org/TR/rdf11-schema/) and [SHACL](https://www.w3.org/TR/shacl/), and each [property shape](https://www.w3.org/TR/shacl/#property-shapes) a class lists draws as a row in its node's **Instance properties** table, with the value it takes and how many. A node takes the shape its type calls for: `desert-ridge`, a solar installation, draws its values as rows, and SolarInstallation, with the **Class Schema** badge, draws its property shapes as this table.

```turtle
# A SolarInstallation is a photovoltaic power plant connected to the grid.
# It has every PowerPlant property, and adds an optional panel count.
:SolarInstallation a svs:ClassSchema ;
  rdfs:label "Solar installation"@en ;
  rdfs:comment "A photovoltaic power plant connected to the grid."@en ;
  rdfs:subClassOf :PowerPlant ;
  sh:property [
    sh:path :panelCount ;
    sh:name "panel count"@en ;
    sh:description "Number of photovoltaic panels installed."@en ;
    sh:datatype xsd:integer
  ] .
```

Figure: The Solar installation node in Folio's Graph View, with its address and a Class Schema badge. Its rows read subClassOf Power plant and comment A photovoltaic power plant connected to the grid. Its Instance properties table lists capacity (MW) decimal 0..*, commissioned on date 0..*, EIA plant code 0..*, grid region 0..*, name string 1..1, operating status 0..*, operator Company 0..*, panel count integer 0..*, phase capacities (MW) 0..* and point of interconnection Grid connection 0..*.

SolarInstallation in plants.ttl. Its own panel count sits beside the nine properties it inherits from PowerPlant under the [inherited-properties rule](https://semvia.io/docs/modeling/inference#inherited-properties).

## A block inside a block

Graph View draws the inner block as a group inside the outer block's group. Here the point of interconnection holds the interconnection agreement it operates under.

```turtle
plants:pointOfInterconnection [
  a plants:GridConnection ;
  plants:substation "Palo Verde" ;
  plants:voltageKV 230 ;
  plants:agreement [
    a plants:InterconnectionAgreement ;
    plants:agreementId "IA-2291" ;
    plants:signedOn "2023-02-14"^^xsd:date
  ]
] .
```

Figure: The desert-ridge node with its Solar installation badge and rows capacityMW 240, name Desert Ridge Solar and operator Helios Energy. Its POINTOFINTERCONNECTION group holds an AGREEMENT group with agreementId IA-2291 and signedOn 2023-02-14, then substation Palo Verde and voltageKV 230. A PHASECAPACITIESMW group with rows 1 and 2, each 120, closes the node.

The agreement block, drawn as a group inside the point of interconnection group.

A block more than two levels down keeps its own node, linked from the row that holds it.

[Next: Markdown syntax](https://semvia.io/docs/authoring/markdown): What each Markdown element means to a mapping, and Folio's special syntax.
