Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:50:36+00:00 2026-06-14T17:50:36+00:00

I have a networkx graph, and I would like to send a node (including

  • 0

I have a networkx graph, and I would like to send a node (including its attributes) through a connection using json format. I know how to serialize the whole graph:

import networkx as nx
from networkx.readwrite import json_graph
G=nx.Graph()
G.add_node(1)
G.node[1]["name"]="alice"
G.add_node(2)
G.add_edge(1,2)
print json.dumps(json_graph.node_link_data(G))

However, I didn’t find a way to serialize a single node, something like

print json.dumps(json_graph.node_data(G.node[1]))

Is there a way to achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:50:37+00:00Added an answer on June 14, 2026 at 5:50 pm

    You could call json.dumps() on the node or a tuple of (node,data).
    The same would work for edges. For example:

    In [1]: import networkx as nx
    
    In [2]: G=nx.Graph()
    
    In [3]: G.add_node(1,color='red',size=75)
    
    In [4]: G.add_node(2,color='blue',size=33)
    
    In [5]: import json
    
    In [6]: json.dumps(G.nodes(data=True))  # all nodes
    Out[6]: '[[1, {"color": "red", "size": 75}], [2, {"color": "blue", "size": 33}]]'
    
    In [7]: json.dumps((1,G.node[1])) # (node, data) tuple
    Out[7]: '[1, {"color": "red", "size": 75}]'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built-in tuple which looks like (u,v) . They are generated by Networkx
Using Python's Networkx library, I created an undirected graph to represent a relationship network
I have a networkx graph. I am adding nodes by adding edges G.add_edge(route[i-1],route[i]); Now
I'm working on some code for a directed graph in NetworkX, and have hit
I have a set of randomly generated formal graphs, and I would like to
I have got a problem like this: We are given a bipartite graph. For
I have around 3500 flood control facilities that I would like to represent as
I have a program written in python using the module networkx to create a
I have a networkx graph which contains nodes whose positions in the graph are
I have a test site where I am building a d3-based force-directed network graph

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.