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!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With