S
S
sr362020-02-12 11:53:39
Algorithms
sr36, 2020-02-12 11:53:39

How to generate a directed graph with N number of paths?

Good afternoon.

It is necessary to write an algorithm that will generate a directed graph, with the exact number of possible options for moving between points A and B.

That is, we have 2 points, let's conditionally call point A the sending point, and point B the delivery daughter.
In the simplest case, we have 2 nodes A and B and one edge between them.
If we pass 4 as input to the algorithm, for example, it should return a random directed graph, in which there are only 4 options for moving between A and B.

I would be grateful for any hints

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2020-02-12
@sr36

We find a partition of the number of paths into prime factors. We build additional layers between points A and B, in each of which the number of points corresponds to the next factor. We connect point A with all points of the first layer, each of the points of the first layer with all points of the second layer, etc., all points of the last layer with point B.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question