I’m using a dictionary to represent a graph in my Python program. I’m using the keys of the dictionary to represent vertices and the values to represent the adjacent nodes of each vertex. The dictionary currently looks like this:
{
'v1' : ['v2','v3'],
'v2' : ['v1'],
'v3' : ['v1','v4'],
'v4' : ['v3']
// And so on.
}
Is there a straightforward way to create a new igraph object from this dictionary? If there’s no easy way, what’s the next-best option?
Well, according to the docs, it seems that
igraphexpectsverticesencoded asintegers. So you need to specify amappingfrom yourverticestointegersand then you could actually proceed for example like this: