You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add function to produce edges in all simple paths (migrated from Trac #732) #718
Comment in Trac by trac user sergionery, 2012-07-08
In order to implement the all_circular_paths function, it was implemented a new version of simple_cycles function. The idea is to use this function in both undirected graphs or multigraphs.
Comment in Trac by trac user sergionery, 2012-07-09
Changes in simple_paths9.py:
added a new function
'''
paths_edges(G,path,data=False)
'''
that, receiving a graph and a path (simple list of nodes), returns (an iterator for) the edges of path. This function can be used in conjunction with a lot of other functions that return paths (all_simple_paths, all_shortest_paths, simple_cycles) making very simple to retrieve their edges, even for a MULTIGRAPH ^(see NOTE)^.
This function can receive as input a (Di)Graph or a Multi(Di)Graph, with the optional parameter data=(False|True). When the data parameter is True, the function outputs all edges data, in this format for each edge:
'''
(u,v,{data})
'''
for (Di)Graphs, or
'''
(u,v,{key: {data}})
'''
for Multi(Di)Graphs
Obs:The given path must be a valid path in a graph G - but it is possible to add a try/except to handle this issue.
changed the edge function ^(see NOTE)^
'''
all_simple_paths_edges
'''
added new edges functions ^(see NOTE)^
'''
all_circular_paths_edges, and all_shortest_paths_edges
'''
NOTE: Due the new added function path_edges, the 'EDGES' functions became very simple to implement. For this reason, perhaps the NEW 'EDGES' functions:
'''
all_simple_paths_edges, all_circular_paths_edges, and all_shortest_paths_edges
'''
won't be necessary any more.
If you are not using the development version of NetworkX, you can implement pairwise yourself by doing something like pairwise = lambda l: zip(l, l[1:]).
Activity
networkx-trac commentedon Jul 20, 2012
Comment in Trac by trac user sergionery, 2012-06-14
Changes in simple_paths8.py:
To do:
networkx-trac commentedon Jul 20, 2012
Attachment in Trac by trac user sergionery, 2012-06-14: simple_paths8.py
networkx-trac commentedon Jul 20, 2012
Attachment in Trac by trac user sergionery, 2012-07-08: simple_cycles.py
networkx-trac commentedon Jul 20, 2012
Comment in Trac by trac user sergionery, 2012-07-08
In order to implement the all_circular_paths function, it was implemented a new version of simple_cycles function. The idea is to use this function in both undirected graphs or multigraphs.
networkx-trac commentedon Jul 20, 2012
Comment in Trac by trac user sergionery, 2012-07-09
Changes in simple_paths9.py:
added a new function
'''
paths_edges(G,path,data=False)
'''
that, receiving a graph and a path (simple list of nodes), returns (an iterator for) the edges of path. This function can be used in conjunction with a lot of other functions that return paths (all_simple_paths, all_shortest_paths, simple_cycles) making very simple to retrieve their edges, even for a MULTIGRAPH ^(see NOTE)^.
This function can receive as input a (Di)Graph or a Multi(Di)Graph, with the optional parameter data=(False|True). When the data parameter is True, the function outputs all edges data, in this format for each edge:
'''
(u,v,{data})
'''
for (Di)Graphs, or
'''
(u,v,{key: {data}})
'''
for Multi(Di)Graphs
Obs:The given path must be a valid path in a graph G - but it is possible to add a try/except to handle this issue.
changed the edge function ^(see NOTE)^
'''
all_simple_paths_edges
'''
added new edges functions ^(see NOTE)^
'''
all_circular_paths_edges, and all_shortest_paths_edges
'''
NOTE: Due the new added function path_edges, the 'EDGES' functions became very simple to implement. For this reason, perhaps the NEW 'EDGES' functions:
'''
all_simple_paths_edges, all_circular_paths_edges, and all_shortest_paths_edges
'''
won't be necessary any more.
networkx-trac commentedon Jul 20, 2012
Attachment in Trac by trac user sergionery, 2012-07-09: simple_paths9.py
amirc commentedon Aug 9, 2016
Hi,
Any chance that someone still has the file simple_paths9.py ?
I'm looking for it because I'm trying to do something similar to this question.
Thanks,
Amir.
jfinkels commentedon Aug 24, 2016
To get the paths as edges, you can do something like
If you are not using the development version of NetworkX, you can implement pairwise yourself by doing something like
pairwise = lambda l: zip(l, l[1:]).