Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python-IGraph Attributes

Tags:

python

igraph

I am looking into converting some code from Python NetworkX to Python-IGraph. When adding nodes and edges to a graph, NetworkX very easily allows you to do: g.add_node(a[0], n=a[1]) where a[0] is the node label and a[1] is the value of the attribute "n". How can we add attributes to a node and similarly to an edge, when creating them with Python-IGraph? Thank you!

like image 976
Gokce Dilek Avatar asked Aug 01 '26 07:08

Gokce Dilek


1 Answers

Welcome to Stack Overflow! What you're looking for is here (edges and vertices). Here's the overview:

To add an edge or vertex with an attribute:

g.add_edge(source, target, some_attribute=some_value)

g.add_vertex(name, some_attribute=some_value)

like image 69
rchurch4 Avatar answered Aug 03 '26 23:08

rchurch4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!