A Vega-Lite example that uses JSON data exported from Gephi: The Open Graph Viz Platform.
An example Neo4J database was copied from SPOKE. It was imported, queried and exported, converted, loaded into Gephi, and exported as a JSON Graph (File/Export/Graph file...
). The data is embedded in the Vega-Lite spec (vis.vl.json
) as two datasets: nodes
and edges
. The spec renders nodes and edges according to the color and size encodings created in Gephi. All attributes available to Gephi are available in the Vega-Lite spec for further customization as needed.
Specific steps for data generation are below.
// Part Of Tree
MATCH (n:Anatomy)
MATCH (n2:Anatomy)
MATCH (n)-[rels:PARTOF_ApA]-(n2)
WITH collect(distinct n) as a, collect(distinct rels) as b
CALL apoc.export.json.data(a, b, "anatomy.json", {stream: true, writeNodeProperties: false})
YIELD file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data
RETURN file, source, format, nodes, relationships, properties, time, rows, batchSize, batches, done, data
# Extract nodes from export
cat <(echo "id,identifier,label") <(jq -r 'select(.type == "node") | ([.id, .properties.identifier, .properties.name]) | @csv' import/anatomy.json) > nodes.csv
# Extract edges from export
cat <(echo "source,type,target") <(jq -r 'select(.type == "relationship") | ([.start.id, .label, .end.id]) | @csv' import/anatomy.json) > edges.csv
File/Export/Graph file...
) to graph.json