DyNetx Logo
  • Overview
    • Who uses DyNetx?
    • Goals
    • The Python DyNetx library
    • Free software
  • Download
    • Software
    • Documentation
  • Installing
    • Note
      • Quick install
      • Installing from source
      • Requirements
  • DyNetx Tutorial
    • Creating a graph
      • Interactions
      • Nodes
    • Read graph from file
      • Snapshot Graph
      • Interaction Graph
    • Snapshots and Interactions
    • Slicing a Dynamic Network
    • Obtain the Interaction Stream
  • Reference
    • Graph types
      • Which graph class should I use?
      • Basic graph types
    • Algorithms
      • Paths
    • Functions
      • Graph
      • Nodes
      • Interactions
      • Freezing graph structure
      • Snapshots and Interaction Stream
    • Reading and writing graphs
      • Edge List
      • JSON
DyNetx
  • Reference
  • Reading and writing graphs
  • JSON
  • dynetx.readwrite.json_graph.node_link_data
  • Edit on GitHub

dynetx.readwrite.json_graph.node_link_data¶

dynetx.readwrite.json_graph.node_link_data(G, attrs={'id': 'id', 'source': 'source', 'target': 'target'})¶

Return data in node-link format that is suitable for JSON serialization and use in Javascript documents.

Parameters¶

G : DyNetx graph

attrsdict

A dictionary that contains three keys ‘id’, ‘source’ and ‘target’. The corresponding values provide the attribute names for storing DyNetx-internal graph data. The values should be unique. Default value dict(id='id', source='source', target='target').

Returns¶

datadict

A dictionary with node-link formatted data.

Examples¶

>>> from dynetx.readwrite import json_graph
>>> import dynetx as dn
>>> G = dn.DynGraph([(1,2)])
>>> data = json_graph.node_link_data(G)

To serialize with json

>>> import json
>>> s = json.dumps(data)

Notes¶

Graph, node, and link attributes are stored in this format. Note that attribute keys will be converted to strings in order to comply with JSON.

See Also¶

node_link_graph

Previous Next

© Copyright 2017, Giulio Rossetti. Revision a0a11418.

Built with Sphinx using a theme provided by Read the Docs.