Generate lists of edges for all simple paths in G from source to target. A simple path is a path with no repeated nodes. Parameters ---------- G : NetworkX graph source : node Starting node for path target : nodes Single node or iterable of nodes at which to end
(G, source, target_nodes, cutoff=None)
| 931 | |
| 932 | |
| 933 | def all_simple_edge_paths(G, source, target_nodes, cutoff=None): |
| 934 | """Generate lists of edges for all simple paths in G from source to target. |
| 935 | A simple path is a path with no repeated nodes. |
| 936 | Parameters |
| 937 | ---------- |
| 938 | G : NetworkX graph |
| 939 | source : node |
| 940 | Starting node for path |
| 941 | target : nodes |
| 942 | Single node or iterable of nodes at which to end path |
| 943 | cutoff : integer, optional |
| 944 | Depth to stop the search. Only paths of length <= cutoff are returned. |
| 945 | Returns |
| 946 | ------- |
| 947 | paths: list |
| 948 | A list that produces lists of simple edge paths. If there are no paths |
| 949 | between the source and target within the given cutoff the list |
| 950 | is empty. |
| 951 | Examples |
| 952 | -------- |
| 953 | Print the simple path edges of a Graph:: |
| 954 | >>> g = nx.Graph([(1, 2), (2, 4), (1, 3), (3, 4)]) |
| 955 | >>> print(nx.builtin.all_simple_paths(G, 1, 4)) |
| 956 | [(1, 2), (2, 4)] |
| 957 | [(1, 3), (3, 4)] |
| 958 | |
| 959 | """ |
| 960 | |
| 961 | paths = get_all_simple_paths(G, source, target_nodes, cutoff) |
| 962 | for path in paths: |
| 963 | a = "" |
| 964 | b = "" |
| 965 | for i in range(len(path) - 1, -1, -1): |
| 966 | if path[i] == -1: |
| 967 | a = path.pop(i) |
| 968 | else: |
| 969 | b = path.pop(i) |
| 970 | if a != -1 and a != "": |
| 971 | path.insert(i, (b, a)) |
| 972 | a = b |
| 973 | return paths |
| 974 | |
| 975 | |
| 976 | def betweenness_centrality( |
nothing calls this directly
no test coverage detected