Problem with add_edge_list(eprop=x)

I'd like to use the "add_edge_list" function to add edges to my graph, and
simultaneously assign a value for an edge property map for each of the added
edges.

When I try the following example (with no edge property map information)
works fine:

elist1 = np.array([[0,1], [1, 2]]) #edge list with no value for edge
property map data (only the source and target for the edges)
g = gt.Graph()
my_eprop = g.new_edge_property('bool')
g.add_edge_list(elist)

But with the following example, I get the error below:

elist2 = np.array([[0,1, 1], [1, 2, 0]]) #edge list with edge property map
value in 3rd column
g = gt.Graph()
my_eprop = g.new_edge_property('bool')
g.add_edge_list(elist2, eprops=my_eprop)

Error:

The 'eprops' parameter expects a list. The last line should have been:

  g.add_edge_list(elist2, eprops=[my_eprop])

Best,
Tiago

Thanks!

attachment.html (1.42 KB)

Sir,

How to add multiple edge properties?
If my_eprop and other_eprop are two arrays of edge properties and there is
another column of values in elist2, then

g.add_edge_list(elist2,eprops=[my_eprop,other_eprop])

Is this correct or not?

This doesn't give any error but it takes only the second property column
from elist2 while ignores the first one.

If you want us to understand the problem you are having, you must provide a
minimal and self-contained example that shows it, otherwise there is little
we can do.

Best,
Tiago

I have a data frame where I have five columns. First two columns are the
source and sink nodes of interaction while the other three columns are three
kinds of edge properties.

*import pandas as pd
import graph_tool as gt

df = pd.DataFrame({'S':['a','b','c'], 'D':['b','c','a'],
'w1':[0.2,0.5,0.6], 'w2':[0.4,0.55,0.99], 'w3':[1,3,5]})

g = gt.Graph()

eprop1 = g.new_edge_property('float')
eprop2 = g.new_edge_property('float')
eprop3 = g.new_edge_property('int')*

Now if I want to add this to the properties to my network then

*g.edge_properties['eprop1'] = eprop1
g.edge_properties['eprop2'] = eprop2
g.edge_properties['eprop3'] = eprop3

This works perfectly for me. In fact, the version with eprops=[eprop1] does
not work, as the number of columns is unmatched.

What version of graph-tool are you using?

Best,
Tiago

Its' working when I changed the edge property type 'int' to 'float' for the
last one.

Also, the assigned property values are reversed in order when I tried the
same for another example with only two property maps.

So for now, the problem seems to have solved.

Graph Tool version is 2.27

Its' working when I changed the edge property type 'int' to 'float' for the
last one.

I can't reproduce this. The example you gave works as expected, regardless
of the property type.

Note that so far you have not produced a minimal example that even allegedly
reproduces the problem you are encountering. For some reason you gave us an
example that _works_ instead of one that doesn't. Could you please provide a
complete and minimal example that _shows_ the problem, i.e. gives the wrong
output?

Also, the assigned property values are reversed in order when I tried the
same for another example with only two property maps.

I can't reproduce this either. And as already explained many times, it is
useless to mention problems without a reproducible example.

So for now, the problem seems to have solved.

???

If the problems you mention are really there, then they need to be fixed. I
ask of you to please produce a minimal and complete example for them.

Best,
Tiago

*import graph_tool as gt

netCoex = gt.Graph() *#create a network