Create a graph from path_iterator results

Hello,

I currently use NetworkX to calculate my network analyses. I would like to switch to the graph-tools library which is much faster and more efficient.
I would like to be able to create a graph from the results of a path search.

My goal is to extract a subgraph that contains only the edges and nodes that are located between two of the source and target nodes (this nodes included).

Draft example :

import graph_tool.all as gt
g = gt.collection.data["football"]
g2 = gt.Graph(directed=False)
for path in gt.all_paths(g, 13, 2, cutoff=2):
    # extract in g the nodes/edges found in path like the path_graph function in NetworkX and keep all informations 
    g_tmp = ????
    # add this new graph in g2
    gt.graph_union(g2, g_tmp, include = True)

thanks in advance,

There’s no point in keeping g_tmp around if all you want is to add edges to g2:

import graph_tool.all as gt
g = gt.collection.data["football"]
g2 = gt.Graph(directed=False)
for path in gt.all_paths(g, 13, 2, cutoff=2, edges=True):
    for e in path:
        g2.add_edge(e.source(), e.target())