I am using the python-igraph library with Python 3. I am trying to code a community detection algorithm which involves converting a graph to its linegraph, using the function linegraph().
There are attributes associated with each edge in the original graph, and I would like them to be copied over as vertex attributes in the linegraph, however this is not the case at the moment.
Does anyone know how I can do this?
What I've tried:
# Setting attributes
for edge in originalGraph.es:
edge['name'] = "".join(str(edge.tuple))
linegraph = originalGraph.linegraph()
# Testing
print(orginalGraph.es[0].attributes())
print(linegraph.vs[0].attributes())
Prints out:
{'name': '(1, 7)'}
{}
As you can see, the 'name' attribute is correctly associated with the edge of the original graph, but not with the vertex of the linegraph.
I might have to code my own function for converting to a linegraph, but I would prefer not to have to do this.