Skip to content

JSON structures stored in GraphSpace databases

Aditya Bharadwaj edited this page Mar 13, 2017 · 2 revisions

We would like to split our json structures into three types of json structure:

  1. Graph Structure
  2. Style
  3. Node positions

This information will be stored in two tables

  1. graph table a. graph_json - structure of the graph and their annotations b. style_json - base styling of the graph.

  2. layout table - layout consists of both location and style information. a. positions_json - map of node locations b. style_json - styling for the layout

Here is the format of all the three JSON structures:

GRAPH JSON

elements: nodes: data: position: edges: data: position: data:

POSITIONS JSON

{
	'<node_id>': {
			'x': 27.22,
			'y': 11.98
		},
		....
}

STYLE JSON

[
	{
	  selector: 'node',
	  style: {
		'background-color': 'red'
	  }
	},
	...
]

The format accepted by GraphSpace will look like this:

elements: nodes: data: positions: edges: data: data: tags: description: name:

aand stored in graph JSON on upload:

GRAPH JSON

elements: nodes: data: positions: edges: data: data: tags: description: name:

The aim of the migration is to change the following convert from old graph JSON format to new graph JSON format.

OLD graph JSON format looks like this:

graph: nodes: data: id: content: background_color: shape: ... position: x: y: edges: data: source: target: background_color: shape: ... position: x: y: metadata: tags: description: name:

NEW graph JSON format looks like this:

GRAPH JSON

elements: nodes: data: id: content: position: x: y: edges: data: source: target: position: x: y: data: tags: description: name:

STYLE JSON

[ { selector: 'node', style: { 'background-color': 'red' } }, ... ]

OLD layout JSON format looks like two different format:

OLD format 1:

{
	'<node_id>': {
			'x': 27.22,
			'y': 11.98
		},
		....
}

OLD format 2:

[
	{
		'x': 27.22,
		'y': 11.98,
		'id': '<node_id>'
	},
		....
]

NEW layout JSON format looks like this:

positions_json

{ '<node_id>': { 'x': 27.22, 'y': 11.98 }, .... },

style_json

[ { selector: 'node', style: { 'background-color': 'red' } }, ... ]

Clone this wiki locally