Hello everyone,



I am trying to add edges to a graph
(through IDs), however this does not seem to work. I know how to add
them by using the vertex number, however being able to add them by
their ID would really make things much easier for me.



I have:
>>>node_list  = ['v1','v2',...]         
(a list of IDs)

I create the graph:
>>>A = Graph(len(nodes_list))
Add the IDs to the graph:
>>>for vertex in
range(len(nodes_list)):

>>>     A.vs[vertex]["id"]=
nodes_list[vertex]




When I actually print these vertices
“>>>  print A.vs[vertex]” I get
>>>igraph.Vertex(<igraph.Graph
object at 0xaa6a0ac>,0,{'id': 'v1'})

>>>igraph.Vertex(<igraph.Graph
object at 0xaa6a0ac>,1,{'id': 'v2'})
...
and so on



Then I create my list of edges:
>>>Edges_list = [('v1', 'v2'), ('v2',
'v3')...]



When I try to add these edges
to the graph 

>>>A.add_edges(Edges_list)



I get the error:



ValueError: no such vertex: 'v1'



Where 'v1' would be any vertex in the
position of the first vertex in the first edge in the list
Edges_list.



I have looked through the
documentation, but I can't find what I am doing wrong.Could you give me any 
suggestions please?Many thanks
Antonio


                                          
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to