What is the number of all possible non-cyclic simple paths in a fully-connected directed graph?

橙三吉。 提交于 2020-01-03 04:25:09

问题


Let's say we have a fully connected digraph G with N vertices and M edges.

How many edges does the graph have? Is it M = N^2?

If we take one vertex and start visiting its neighbors in a 'depth-first search' manner and avoiding loops, how many non-cyclic simple paths will we get?

For example, if we start from vertex 1 in a graph of 4 vertices, here are the paths:

- 1
- 1,2
- 1,3
- 1,4
- 1,2,3
- 1,2,4
- 1,3,2
- 1,3,4
- 1,4,2
- 1,4,3

Is it N! or more for a graph with N vertices? I could not find a way to generalize this and to derive a usable formula.


回答1:


If your graph is full, there are n! simple paths for each vertex, so total of n*n! simple paths in the graph.

let a starting vertex be v_1.
There are |V| possibilities what to do next: move to one of each V\{v_1}, or stop.
next you have |V|-1 possibilities: move to one of each V\{v_1,v_2} [where v_2 is the node chosen as second] or stop.
... [do induction to formally prove it here]
after you have a path of n nodes, there is one only possibility: stop.
giving you total of n*(n-1)*...*1 = n! possible simple paths for each vertex, and n*n! total possible simple paths in the graph



来源:https://stackoverflow.com/questions/8457805/what-is-the-number-of-all-possible-non-cyclic-simple-paths-in-a-fully-connected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!