- From: Anders Riutta <anders.riutta@gladstone.ucsf.edu>
- Date: Thu, 21 Nov 2013 11:04:11 -0800 (PST)
- To: public-linked-json@w3.org
I got the first part working, but I would still be interested in hearing about topological sorting in relation to JSON-LD. My examples on the JSON-LD playground are shown below (click the "Framed" tab after following the link). Frame1: From children nested under parent to children at top level http://json-ld.org/playground/index.html?json-ld=%7B%22%40context%22%3A%7B%22ex%22%3A%22http%3A%2F%2Fexample.com%2Fvocab%23%22%2C%22name%22%3A%22ex%3Aname%22%2C%22dependsOn%22%3A%22ex%3AdependsOn%22%2C%22hasDependencies%22%3A%7B%22%40reverse%22%3A%22ex%3AdependsOn%22%7D%7D%2C%22%40id%22%3A%22%23homer%22%2C%22name%22%3A%22Homer%22%2C%22hasDependencies%22%3A%5B%7B%22%40id%22%3A%22%23bart%22%2C%22name%22%3A%22Bart%22%7D%2C%7B%22%40id%22%3A%22%23lisa%22%2C%22name%22%3A%22Lisa%22%7D%5D%7D&frame=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22ex%22%3A%20%22http%3A%2F%2Fexample.com%2Fvocab%23%22%2C%0A%20%20%20%20%22name%22%3A%20%22ex%3Aname%22%2C%0A%20%20%20%20%22dependsOn%22%3A%20%22ex%3AdependsOn%22%2C%0A%20%20%20%20%22hasDependencies%22%3A%20%7B%0A%20%20%20%20%20%20%22%40reverse%22%3A%20%22ex%3AdependsOn%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22hasDependencies%22%3A%20%7B%7D%0A%7D&context=%7B%7D&startTab=tab-framed Frame2: From children at top level to children nested under parent (reverse of Frame1): http://json-ld.org/playground/index.html?json-ld=%7B%22%40context%22%3A%7B%22ex%22%3A%22http%3A%2F%2Fexample.com%2Fvocab%23ex%22%2C%22name%22%3A%22ex%3Aname%22%2C%22hasDependencies%22%3A%22ex%3AhasDependencies%22%2C%22dependsOn%22%3A%7B%22%40reverse%22%3A%22ex%3AhasDependencies%22%7D%7D%2C%22%40graph%22%3A%5B%7B%22%40id%22%3A%22%23bart%22%2C%22dependsOn%22%3A%7B%22%40id%22%3A%22%23homer%22%2C%22name%22%3A%22Homer%22%7D%2C%22name%22%3A%22Bart%22%7D%2C%7B%22%40id%22%3A%22%23homer%22%2C%22name%22%3A%22Homer%22%7D%2C%7B%22%40id%22%3A%22%23lisa%22%2C%22dependsOn%22%3A%7B%22%40id%22%3A%22%23homer%22%2C%22name%22%3A%22Homer%22%7D%2C%22name%22%3A%22Lisa%22%7D%5D%7D&frame=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22ex%22%3A%20%22http%3A%2F%2Fexample.com%2Fvocab%23ex%22%2C%0A%20%20%20%20%22name%22%3A%20%22ex%3Aname%22%2C%0A%20%20%20%20%22hasDependencies%22%3A%20%22ex%3AhasDependencies%22%2C%0A%20%20%20%20%22dependsOn%22%3A%20%7B%0A%20%20%20%20%20%20%22%40reverse%22%3A%20%22ex%3AhasDependencies%22%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%22hasDependencies%22%3A%20%7B%7D%0A%7D&context=%7B%7D&startTab=tab-framed I have several code examples here: https://github.com/ariutta/json-ld-examples Anders ----- Original Message ----- From: "Anders Riutta" <anders.riutta@gladstone.ucsf.edu> To: public-linked-json@w3.org Sent: Wednesday, November 20, 2013 3:23:08 PM Subject: Framing and @reverse Hello, I am looking at using JSON-LD for a project I'm working on but am running into some difficulties. The data can be represented as a collection of directed acyclic graphs, and it needs to go through a topological sort. I'm trying to first transform the collection from the form "A-dependsOn-B, B-dependsOn-C" to the reverse, compacted form "C-hasDependencies-[A, B]" so I can use an algorithm like <https://github.com/davidstutz/d3-topological>. I think this transformation should be possible with JSON-LD, but I'm having difficulty making it happen. Here's a non-working code sample on the JSON-LD playground: http://json-ld.org/playground/index.html?json-ld=%7B%22%40context%22%3A%7B%22dc%22%3A%22http%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%22%2C%22ex%22%3A%22http%3A%2F%2Fexample.org%2Fvocab%23%22%2C%22xsd%22%3A%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%22%2C%22ex%3AdependsOn%22%3A%7B%22%40type%22%3A%22%40id%22%7D%2C%22ex%3AhasDependency%22%3A%7B%22%40reverse%22%3A%22ex%3AdependsOn%22%7D%7D%2C%22%40graph%22%3A%5B%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2FwakeUp%22%2C%22%40type%22%3A%22ex%3AEvent%22%2C%22dc%3Atitle%22%3A%22Wake%20Up%22%7D%2C%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2FmakeCoffee%22%2C%22%40type%22%3A%22ex%3AEvent%22%2C%22dc%3Atitle%22%3A%22Make%20Coffee%22%2C%22ex%3AdependsOn%22%3A%22http%3A%2F%2Fexample.org%2FwakeUp%22%7D%2C%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2FmakeToast%22%2C%22%40type%22%3A%22ex%3AEvent%22%2C%22dc%3Atitle%22%3A%22Make%20Toast%22%2C%22ex%3AdependsOn%22%3A%22http%3A%2F%2Fexample.org%2FwakeUp%22%7D%2C%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2FhaveBreakfast%22%2C%22%40type%22%3A%22ex%3AEvent%22%2C%22dc%3Atitle%22%3A%22Have%20Breakfast%22%2C%22ex%3AdependsOn%22%3A%5B%22http%3A%2F%2Fexample.org%2FmakeCoffee%22%2C%22http%3A%2F%2Fexample.org%2FmakeToast%22%5D%7D%5D%7D&frame=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22dc%22%3A%20%22http%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%22%2C%0A%20%20%20%20%22ex%22%3A%20%22http%3A%2F%2Fexample.org%2Fvocab%23%22%0A%20%20%7D%2C%0A%20%20%22%40type%22%3A%20%22ex%3AEvent%22%2C%0A%20%20%22ex%3AhasDependency%22%3A%20%7B%0A%20%20%20%20%22%40type%22%3A%20%22ex%3AEvent%22%0A%20%20%7D%0A%7D&context=%7B%0A%20%20%22%40context%22%3A%20%7B%0A%20%20%20%20%22dc%22%3A%20%22http%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%22%2C%0A%20%20%20%20%22ex%22%3A%20%22http%3A%2F%2Fexample.org%2Fvocab%23%22%2C%0A%20%20%20%20%22xsd%22%3A%20%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%22%2C%0A%20%20%20%20%22ex%3Acontains%22%3A%20%7B%0A%20%20%20%20%20%20%22%40type%22%3A%20%22%40id%22%0A%20%20%20%20%7D%0A%20%20%7D%0A Thanks for any suggestions! Anders
Received on Thursday, 21 November 2013 19:04:36 UTC