-
-
Notifications
You must be signed in to change notification settings - Fork 206
Open
Labels
featurea feature request or enhancementa feature request or enhancement
Description
Describe the bug
graph_from_literal()
does not preserve the edge order, which makes it inconvenient (and confusing) to set edge attributes on a graph right after creation. There is an instance of this going wrong here: https://stackoverflow.com/q/76345800/695132
graph <- graph.formula(
A -+ B,
B -+ C,
C -+ D,
D -+ E,
A -+ D,
B -+ D,
B -+ E
)
E(graph)$weight <- c(3, 2, 4, 5, 5, 1, 4)
The user assumed that A -> B
will have weight 3, B->C
weight 2, and so on. But this is not the case.
To reproduce
Notice that the edge order of the graph does not correspond to the edge order used in the creation formula.
> g <- graph_from_literal(A -+ B, B -+ C, C -+ D, D -+ E, A -+ D, B -+ D, B -+ E)
> E(g)
+ 7/7 edges from e733585 (vertex names):
[1] A->B A->D B->C B->D B->E C->D D->E
Both the Python and Mathematica interfaces preserve the edge order. It was surprising to me to discover that the R interface does not.
Version information
1.4.3 and igraph_1.4.99.9014
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement