Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This does not appear to be implemented in sage. The code below may be an option to get that functionality

def all_paths(G,a,b):
    paths = G.all_paths( a, b ) # get all paths without edge multiplicity
    multi_paths=[]
    for p in paths: # we will traverse each path replacing each edge by a list of (multi) edges
        multi_edges=[]
        for i,u in enumerate(p):
            if i < len(p)-1:
                v = p[i+1]
                edges = A.edge_boundary([u], [v] )
                multi_edges.append(edges)
        multi_paths.append( multi_edges ) # each sequence of (multi) edges will be a source of multiple paths 
    paths = []
    for multi_path in multi_paths:
        paths.extend(CartesianProduct(*multi_path)) # we extract all possible paths from a given multi path
    return paths

Then you can use

paths=all_paths(A,1,3)
print len(paths)
for p in paths:
    print p

This does not appear to be implemented in sage. The code below may be an option to get that functionality

def all_paths(G,a,b):
    paths old_paths = G.all_paths( a, b ) # get all paths without edge multiplicity
    multi_paths=[]
new_paths=[]
    for p in paths: old_paths: # we will traverse each path replacing each edge by a list of (multi) edges
        multi_edges=[]
multi_path=[]
        for i,u in enumerate(p):
            if i < len(p)-1:
                v = p[i+1]
                edges = A.edge_boundary([u], [v] )
                multi_edges.append(edges)
        multi_paths.append( multi_edges ) multi_path.append(edges)
        new_paths.extend( CartesianProduct(*multi_path )) # each sequence of (multi) edges will be a source of multiple paths 
    paths = []
    for multi_path in multi_paths:
        paths.extend(CartesianProduct(*multi_path)) # we extract all possible paths from a given multi path
paths
    return paths
new_paths

Then you can use

paths=all_paths(A,1,3)
print len(paths)
for p in paths:
    print p

This does not appear to be implemented in sage. The code below may be an option to get that functionality

def all_paths(G,a,b):
    old_paths = G.all_paths( a, b ) # get all paths without edge multiplicity
    new_paths=[]
    for p in old_paths: # we will traverse each path replacing each edge by a list of (multi) edges
        multi_path=[]
        for i,u in enumerate(p):
            if i < len(p)-1:
                v = p[i+1]
                edges = A.edge_boundary([u], G.edge_boundary([u], [v] )
                multi_path.append(edges)
        new_paths.extend( CartesianProduct(*multi_path )) # each sequence of (multi) edges will be a source of multiple paths
    return new_paths

Then you can use

paths=all_paths(A,1,3)
print len(paths)
for p in paths:
    print p