DyNetx Logo
  • Overview
    • Who uses DyNetx?
    • Goals
    • The Python DyNetx library
    • Free software
  • Download
    • Software
    • Documentation
  • Installing
    • Note
      • Quick install
      • Installing from source
        • Source archive file
        • GitHub
      • Requirements
        • Python
        • Required packages
  • 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
        • Undirected Dynamic Graphs
        • Directed Dynamic Graphs
    • Algorithms
      • Paths
        • Time respecting paths
        • Temporal Directed Acyclic Graph
    • Functions
      • Graph
        • dynetx.classes.function.degree
        • dynetx.classes.function.degree_histogram
        • dynetx.classes.function.density
        • dynetx.classes.function.create_empty_copy
        • dynetx.classes.function.is_directed
        • dynetx.classes.function.add_star
        • dynetx.classes.function.add_path
        • dynetx.classes.function.add_cycle
      • Nodes
        • dynetx.classes.function.nodes
        • dynetx.classes.function.number_of_nodes
        • dynetx.classes.function.all_neighbors
        • dynetx.classes.function.non_neighbors
      • Interactions
        • dynetx.classes.function.interactions
        • dynetx.classes.function.number_of_interactions
        • dynetx.classes.function.non_interactions
      • Freezing graph structure
        • dynetx.classes.function.freeze
        • dynetx.classes.function.is_frozen
      • Snapshots and Interaction Stream
        • dynetx.classes.function.stream_interactions
        • dynetx.classes.function.time_slice
        • dynetx.classes.function.temporal_snapshots_ids
        • dynetx.classes.function.interactions_per_snapshots
        • dynetx.classes.function.inter_event_time_distribution
    • Reading and writing graphs
      • Edge List
        • Format
        • Interaction Graph
        • Snapshot Graphs
      • JSON
        • JSON data
DyNetx
  • Docs »
  • 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) –
  • attrs (dict) – 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:

data – A dictionary with node-link formatted data.

Return type:

dict

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()

Next Previous

© Copyright 2017, Giulio Rossetti Revision a9a2ae22.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.