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

  • SEARCH
  • Home
  • 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 8959645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:29:21+00:00 2026-06-15T15:29:21+00:00

I have a network of nodes created using python networkx . i want to

  • 0

I have a network of nodes created using python networkx. i want to store information in nodes such that i can access the information later based on the node label (the name of the node) and the field that in which the information has been stored (like node attributes). the information stored can be a string or a number I wish to do so in a manner such that if xyz is a node:

then I want to save two or three fields having strings like the date of birth of xyz dob=1185, the place of birth of xyz pob=usa, and the day of birth of xyz dayob=monday.

I know that i can use G.add_node has the attribute dictionary field in it…but I can’t seem to access it for a particular field. if there is any other way i would appreciate it.

i then want to compare xyz with other nodes in the networks having the same information in common. i.e. intersection of node xyz with node abc based on date of bith, place of birth and day of birth

e.g for if nodes xyz and abc have an edge print their respective dobs, their pobs and their dayobs

  • 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-15T15:29:22+00:00Added an answer on June 15, 2026 at 3:29 pm

    As you say, it’s just a matter of adding the attributes when adding the nodes to the graph

    G.add_node('abc', dob=1185, pob='usa', dayob='monday')
    

    or as a dictionary

    G.add_node('abc', {'dob': 1185, 'pob': 'usa', 'dayob': 'monday'})
    

    To access the attributes, just access them as you would with any dictionary

    G.node['abc']['dob'] # 1185
    G.node['abc']['pob'] # usa
    G.node['abc']['dayob'] # monday
    

    You say you want to look at attributes for connected nodes. Here’s a small example on how that could be accomplished.

    for n1, n2 in G.edges_iter():
        print G.node[n1]['dob'], G.node[n2]['dob']
        print G.node[n1]['pob'], G.node[n2]['pob']
        # Etc.
    

    As of networkx 2.0, G.edges_iter() has been replaced with G.edges(). This also applies to nodes. We set data=True to access attributes. The code is now:

    for n1, n2 in list(G.edges(data=True)):
        print G.node[n1]['dob'], G.node[n2]['dob']
        print G.node[n1]['pob'], G.node[n2]['pob']
        # Etc.
    

    NOTE: In networkx 2.4, G.node[] has been replaced with G.nodes[].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python's Networkx library, I created an undirected graph to represent a relationship network
I have a network of blogs that I want to be able to do
I'm using php 5.2 with IIS7.5. I have a network share on a NAS
I have a social network type site (member site) I store a lot of
I have a complex network of objects being spawned from a sqlite database using
Hello I have the Addin for Word 2007 that is creted using VSTO. I
I'm running into trouble with some Python stuff. I have a list that has
I have a network consisting nodes(computers, with ubuntu) with 1 node as root. I
I have a network of nodes, subject to the following properties: The global set
I have a networkx graph. I am adding nodes by adding edges G.add_edge(route[i-1],route[i]); Now

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.