Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

add nodes module #1

Open
yaslena opened this issue Jun 4, 2021 · 0 comments
Open

add nodes module #1

yaslena opened this issue Jun 4, 2021 · 0 comments
Assignees
Labels

Comments

@yaslena
Copy link
Collaborator

yaslena commented Jun 4, 2021

Module description
This module adds new nodes to an existing graph object that has already been generated.

Inputs

  • iterable container (list, dict, set...)
  • new graph

Graph types
All graph types will need this module.

Example code
In the Jupyter notebook there is one example of how this can be done (cell 199-208): https://github.com/DHARPA-Project/NetworkXAnalysis/blob/master/ReviewsNXPandas.ipynb

add nodes:
new_data = new_nodes_unique.set_index('Id').to_dict('index').items()
A.add_nodes_from(new_data)

add edges (by adding a new graph (B) to the old graph(A)):
A.add_edges_from(B.edges(data=True))
General:
Graph.add_nodes_from(nodes_for_adding, **attr)

Parameters
nodes_for_adding: iterable container
A container of nodes (list, dict, set, etc.). OR A container of (node, attribute dict) tuples. Node attributes are updated using the attribute dict.

@yaslena yaslena added the module label Jun 4, 2021
@yaslena yaslena self-assigned this Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant