How to output all directed edges in a (causal) path from a node A to another node B

Hi, I’m new to graph. Suppose I have an acyclic directed mixed graph like the following code.

g <- graph.formula(x -+ w1, x -+ y1, w1 -+ w2, w2 -+ y2,
                   w1 -+ y1, y1 -+ w1, w1 -+ w2, w2 -+ w1, w1 -+ y2, y2 -+ w1, w2 -+ x, x -+ w2, simplify = FALSE)
g <- set.edge.attribute(graph = g, name = "description", index = 5:12, value = "U")

Say I’m interested in the path from x to y2 (x → w1 → w2 → y2). Is there a function/way to output the directed edges between them? The output is a set like this: x -+ w1, w1 -+ w2, w2 -+ y2.

Thanks in advance for any help or insights!

shortest_paths() will find a shortest path between two vertices. The output parameter controls whether to output the vertices along the path, the edges along the path, or both. See Shortest (directed or undirected) paths between vertices — distance_table • igraph


> shortest_paths(g, 'x', 'y2', output='epath')$epath
+ 2/12 edges from 3bcf07b (vertex names):
[1] x ->w1 w1->y2

This graph is not acyclic. There are reciprocal edges like y1 ↔ w1. That’s a 2-cycle. x → w1 → w2 → x is a 3-cycle.

“mixed graph” normally refers to a graph that contains both directed and undirected edges. igraph does not support mixed graphs. Did you mean multigraph?