Find all paths from one node to another in an undirected graph [adjacency list]

六月ゝ 毕业季﹏ 提交于 2020-01-17 05:51:06

问题


So I have a graph in the form of an adjacency list, structured as in the code below. Given this form of a data structure, I was wondering how it would be possible to go about finding and printing all the possible paths from a given node to another node. I'm aware I might have to used stacks to perform a DFS or queues to perform BFS, which I know how to do, but am confused by how to find all the possible paths

typedef struct graph {
    int n, maxn;
    Vertex** vertices;
}Graph;

typedef struct vertex {
    char* label;
    Edge* first_edge;
}Vertex;

typedef struct edge {
    int u, v;
    int weight;
    Edge* next_edge;
}Edge ;

来源:https://stackoverflow.com/questions/43142841/find-all-paths-from-one-node-to-another-in-an-undirected-graph-adjacency-list

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