I am currently looking into the differences between the linegraph()
function compared to a one-node-projection in a bipartite graph and was wondering, if there was a way to conserve the edge attributes and move them to the vertices using the igraph.GraphBase.linegraph()
function?
You can copy the attributes manually with something like:
lg = g.linegraph()
for attr in g.edge_attributes():
lg.vs[attr] = g.es[attr]
You are welcome to submit a feature request to preserve vertex attributes, but please discuss realistic use cases in detail.
Thank you very much for the input.
I wasn’t sure the indexing would be preserved. This should solve my problem and I will think a bit about the use cases.
Good point. We will document that it is preserved.
1 Like
I should point out that when the python-igraph documentation is sparse on details, it’s usually worth checking the C documentation, which tends to give more details:
https://igraph.org/c/html/latest/igraph-Operators.html#igraph_linegraph
I have now updated the python-igraph docs with this information.