directed simple graph, all paths from node $ v_0 $ to an other node $ v $, MATLAB

390 Views Asked by At

consider a directed simple graph $ G=(V,E) $ with $ V=\lbrace v_0,v_1,\ldots,v_k \rbrace $ and adjacency matrix $ A=(a_{ij}) $, where $ a_{ij}=1 $ means, that there is an arc from node $ v_i $ to node $ v_j $, otherwise $ a_{ij}=0 $. Furthermore it holds $ a_{mn}=0 $ for all $ m \ge n$ (i.e. there are no backward arcs or loops).

Let $ v \in V $ be a node of $ G $. Is there a way to compute all paths from $ v_0 $ to $ v $ in MATLAB?

More precisely, I want to do the following: After a path has been found, one has to check, whether this path has a certain property. If the answer is 'yes', then the algorithm can immediately stop and return the value $Result=1 $. If the answer is 'no', one has to search the next path and repeat this procedure. If there is no other path, then $Result=0 $.

I hope, you can help me. Thanks a lot.