Directed graphs and direction of edges

How can i turn a directed graph into an undirected graph, being able to choose the direction of the edges? to_directed gives an arbitrary direction to each edge, right?

Do you mean turn an undirected graph into a directed one? Based on what do you want to choose the edge directions?

For example, we can choose edge directions from low-index vertices to high-index vertices and thus obtain a directed acyclic graph:

g=Graph.Erdos_Renyi(n=20,m=30)
dg=Graph([sorted(e) for e in g.get_edgelist()], directed=True)
dg.vs["label"]=range(dg.vcount())
plot(dg, layout=dg.layout_sugiyama())
dg.is_dag()