Convert Undirected graph to directed graph - algorithm

How do you convert (can we convert?) an Undirected graph into a Directed graph.
I am using Jgrapht library

This is simple, just replace the undirected edge between two nodes A and B with two directed edges. One from A->B and the other from B -> A.

Related

How to turn a directed unweighted graph into a tree, rooted at a given vertex?

If I have a directed unweighted graph and want to create a tree from a specific vertex in the graph thus, giving all paths from said vertex. How would this be done?

Does a DFS produce a MST for an unweighted directed graph?

I'm getting confused from reading online posts. I know that a BFS traversal on an unweighted directed graph will produce a minimum spanning tree and shortest path. Can a DFS traversal on an unweighted directed graph do the same?
Yes, Breadth-First and Depth-First both yield spanning trees. It doesn't make much sense to discuss "minimum spanning tree" for an unweighted graph, because all spanning trees on a given graph with n vertices have the same number of vertices (n) and the same number of edges (n-1).
No, Depth-First does not guarantee shortest path. You really need Breadth-First for that. Consider a cyclic graph:
a - h - g - f
| |
b - c - d - e
Starting from vertex a, there are two possible results to depth-first search: a->b->c->d->e->f->g->h, and a->h->g->f->e->d->c->b. The former returns a very long path from a to h, and the latter returns a very long path from a to b.
Note that in this example, the graph is undirected. But undirected graphs are a special case of directed graphs; you can replace every undirected edge by two directed edges in opposing directions.

If there is a weight 3 from A->B and a weight 1 from B->A, does this mean that there are automatically 2 edges between A and B?

Regarding weighted graphs:
If there is a weight 3 from A->B and a weight 1 from B->A, does this mean that there are 2 edges between A and B? I'm 95% sure that the answer is yes, but I'd like to be certain. I'm trying to see if directed graphs with weight schemes like this are automatically multigraphs.
Thanks for your valuable input!
Marcus
As noted here
A graph with one edge from A to B and one edge from B to A, will simply be called a directed graph, but if we would have a directed graph with multiple edges from A to B, it will be called as multigraph or specifically, in our case, multidigraph.
Like, in the diagram(taken from same link).
In the first graph, there is no case when we have two edges from same origin and destination, so its a normal directed graph. But in case of second graph, there are two edges from e to d and from b to c. Thus, making it a multidigraph.
There are 2 edges between A and B, but they are not the same edge in a directed graph. There is the edge from A to B (A->B) and the edge from B to A (B->A). This does not make the graph a multigraph because those are two distinct edges.
In an undirected multigraph the source and destination nodes do not matter. The edges would no longer be (A->B) and (B->A) . They would simply each become (A, B) indicating an edge between A and B exists. If more than one edge connects any two nodes in an undirected graph, the graph becomes a multigraph.
A Direcited Multigraph must have multiple edges with the same source and destination. If there were multiple edges from A to B, then it would be a directed multigraph. However, you list two distinct directed edges. (A->B) and (B->A). These edges are not identical and so the graph you describe is not a multigraph.

What do you call a fully connected directed graph where each node has at most one outbound edge?

A fully connected directed graph where each node has at most a one inbound edge is a tree. Does a fully connected directed graph where each node has at most a single outbound edge have a name? Anti-tree?!
I believe that this does indeed have a name - it is a directed pseudotree.
From the Wikipedia article on pseudoforests:
A directed pseudoforest is a directed graph in which each vertex has
at most one outgoing edge; that is, it has outdegree at most one. A
directed 1-forest – most commonly called a functional graph, sometimes maximal directed pseudoforest – is a directed graph
in which each vertex has outdegree exactly one.[8] If D is a directed
pseudoforest, the undirected graph formed by removing the direction
from each edge of D is an undirected pseudoforest.
Hence, we can call the graph you describe above a directed pseudoforest. You also note that the graph is connected. From the same page:
A pseudotree is a connected pseudoforest.
Hence, the term directed pseudotree.
Here is the proper definition of an undirected pseudoforest, for your information, from Wolfram Alpha:
A pseudoforest is an undirected graph in which every connected
component contains at most one graph cycle. A pseudotree is therefore
a connected pseudoforest and a forest (i.e., not-necessarily-connected
acyclic graph) is a trivial pseudoforest.
Some care is needed when encountering pseudoforests as some authors
use the term to mean "a pseudoforest that is not a forest."

Convert cyclic directed graph to tree (Arborescence)

I have this requirement, where I want to convert a directed cyclic graph into a tree given 1 vertex, which will be the root.
From my research I found out that I need to create an Arborescence, which HAS to be acyclic, in order to convert it into a tree. Is it impossible to create a directed rooted tree from a cyclic directed graph?
Here's an example of the vertexes and its edges.

Resources