# @equinor/rdf-graph

> Visualize RDF as a graph network

Latest version **0.24.1** (published 2024-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @equinor/rdf-graph
pnpm add @equinor/rdf-graph
yarn add @equinor/rdf-graph
bun add @equinor/rdf-graph
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.24.1 |
| Published | 2024-03-19 |
| First published | 2022-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 157.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Maintainers | daghovland, lorentzfb, dzianis.makeichyk |

## Links

- npm: https://www.npmjs.com/package/@equinor/rdf-graph
- Repository: https://github.com/equinor/rdf-graph
- Homepage: https://github.com/equinor/rdf-graph#readme
- Issues: https://github.com/equinor/rdf-graph/issues
- npm.io page: https://npm.io/package/@equinor/rdf-graph

## Dependencies (1)

- [n3](https://npm.io/package/n3.md) ^1.16.3

## Recent versions

- 0.24.1 (latest) — 2024-03-19
- 0.24.0 — 2024-02-07
- 0.22.0 — 2023-11-29
- 0.21.1 — 2023-04-12
- 0.21.0 — 2023-04-11
- 0.20.0 — 2023-04-03
- 0.19.0 — 2023-02-03
- 0.18.0 — 2023-01-26
- 0.17.2 — 2023-01-20
- 0.17.1 — 2023-01-20
- 0.17.0 — 2023-01-20
- 0.16.0 — 2023-01-18
- 0.15.1 — 2023-01-02
- 0.15.0 — 2022-11-24
- 0.14.1 — 2022-11-15
- … 19 more at https://npm.io/package/@equinor/rdf-graph/versions

## README

# @equinor/rdf-graph - Core Library

[![core version](https://img.shields.io/npm/v/@equinor/rdf-graph)](CHANGELOG.md)

Core package with only one dependency ([N3.js](https://github.com/rdfjs/N3.js/)). Core's responsibility is to transfer addition and / or removal of RDF triples into something called `GraphPatches`. `GraphPatches` are addition or removal of nodes, edges, node properties or edge properties. The purpose of this is to make it easy to visualize rdf in graph visualization tool, but in theory it can be used in any application that wants to convert RDF into a property graph and even modify the RDF and see those changes reflected in the property graph.

## Example

```ts
import { RdfGraph, GraphPatch, GraphState, RdfPatch, turtleToQuads } from '@equinor/rdf-graph';

// Create a RdfGraph state object
const state: GraphState = new RdfGraph({ symbolProvider });

// In this example we want to "add" all RDF triples from some turtle
// data to our custom UI
const turtleString = "....";

// Create a set of RdfPatch'es from our RDF data
// An RdfPatch is simply an object containing an action and a N3 Quad:
//
//    RdfPatch
//
//    { 
//      action: "add" | "remove";
//      data: N3.Quad;
//    }
//
const rdfPatches: RdfPatch[] = turtleToQuads(turtleString)
                    .map(q => ({ action: "add", data: q}));

// Get UI graph patches by patching the rdf-graph state with the RdfPatches
const graphPatches: GraphPatch[] = state.patch(rdfPatches);

// Apply the graph patches to your UI state handler
myAwesomeUiImplementation.applyGraphPatches(graphPatches);
```

## Symbol Provider

TODO

---
_Source: https://npm.io/package/@equinor/rdf-graph · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
