Skip to content

add nodes module #1

@yaslena

Description

@yaslena

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions