Transforming GDF to JSON
Gephi is an excellent tool to get easy and fast results. However, if we want to present the graph interactively on a website, we will need to implement a different kind of visualization. In order to work with the graph in the web, we need to transform our .gdf
file to the JSON format.
First we need to import the libraries numpy
and json
. See Chapter 2, Preprocessing the Data, for more information about the JSON format:
import numpy as np import json
The numpy function genfromtxt
will obtain only the ID and Name from the nodes.csv
file, using the usecols
attribute in the 'object'
format:
nodes = np.genfromtxt("nodes.csv", dtype='object', delimiter=',', skip_header=1, usecols=(0,1))
Then, the numpy function genfromtxt
will obtain links with the source node and target nodes from the links.csv
file, using the usecols
attribute in the 'object...