-
Notifications
You must be signed in to change notification settings - Fork 3
GraphJSON v0.1 Specifications
GraphJSON is heavily influenced by GeoJSON and is a standard format used to describe a graph structure regardless of graph type or content in order to render meaningful graph visualizations, analytics, and other content by any application.
GraphJSON is composed of two main parts, nodes and edges. Nodes are list of nodes in a graph, and edges are the connections between them. Nodes and edges can hold an arbitrary number of key values as properties. For now these are stored directly in the top level node and edge dictionaries.
JavaScript Object Notation (JSON), and the terms object, name, value, array, and number, are defined in IETF RTC 4627, at http://www.ietf.org/rfc/rfc4627.txt.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in IETF RFC 2119, at http://www.ietf.org/rfc/rfc2119.txt.
The GraphJSON data structure is JSON object with a list of node dictionaries under the nodes key and a list of edge dictionaries under the edges key.
Nodes can have an arbitary number of properties to several different purposes in an application.
Currently, the only required key is:
- id: a unique str or integer that is used in edges to identify source and target nodes.
Optional keys can include:
- caption: the field that will appear on a node with an application defined interaction (e.g. click, or :hover)
All other type level keys, are used based on the unique application.
Edges can have an arbitary number of properties to several different purposes in an application.
Currently, edges require the following keys:
- source: a unique str or integer that is used by the nodes id field
- target: a unique str or integer that is used by the nodes id field
Optional keys can include:
- caption: the field that will appear on a relationship with an application defined interaction (e.g. click, or :hover)
All other type level keys, are used based on the unique application.
You can find full set of data for the below example here.
The GraphJSON data below is a snippet of a large GraphJSON file. The snippet on its own would generate the following graph:
In the below snippet the node has the necessary property id 61016 and has a caption property "Kevin Bacon". While the caption property happens to be the same as the name property, all the other properties - mid (the [Freebase] machine id), node_type, genre, type, and name are arbitrary and to be used by the application directly.
Additionally, the two visible relationships are the edges between Kevin Bacon's node (id: 61016), where Kevin is the source, and the X-Men node (id: 744682) and the Losing Chase node (id: 821223) where they are the targets. The edge between Kevin and X-Men stores an acted in caption as well as a role property. Meanwhile, the edge between Kevin and the Losing Chase node stores a directed caption. (A TV Film directed by Kevin Bacon? I wonder why we've never seen it.)
{
"nodes": [...,
{
"name": "Kevin Bacon",
"mid": "/m/04954",
"caption": "Kevin Bacon",
"node_type": "person",
"genre": [],
"type": "person",
"id":
},
{
"name": "X-Men: First Class",
"mid": "/m/0cd2vh9",
"caption": "X-Men: First Class",
"node_type": "movie",
"genre": [
"Science Fiction",
"Action film",
"Action/Adventure",
"Adventure film",
"Thriller",
"Fantasy",
"Superhero movie",
"Drama"
],
"type": "movie",
"id": 744682
},
{
"name": "Losing Chase",
"mid": "/m/08yrpyp",
"caption": "Losing Chase",
"node_type": "movie",
"genre": [
"Romance Film",
"LGBT",
"Drama"
],
"type": "movie",
"id": 821223
},
...]
"edges": [...,
{
"source": 61016,
"role": "Sebastian Shaw",
"target": 744682,
"caption": "acted in"
},
{
"source": 61016,
"target": 821223,
"caption": "directed"
},
...]
{