Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find edges in a graph that connect one vertex to another
ResourceFunction["FindPathEdges"][g,s,t] finds a path between vertex s and vertex t in the graph g and returning the path as a list of edges. | |
ResourceFunction["FindPathEdges"][g,{v1,v2,…}] converts a vertex path in graph g to an edge path. | |
ResourceFunction["FindPathEdges"][g,{path1,path2,…}] converts a list of vertex paths. |
Find a path between two individual vertices in a graph:
In[1]:= | ![]() |
In[2]:= | ![]() |
Out[2]= | ![]() |
Highlight the path:
In[3]:= | ![]() |
Out[3]= | ![]() |
Convert a vertex path to an edge path:
In[4]:= | ![]() |
Out[4]= | ![]() |
Find all paths between two individual vertices in a graph:
In[5]:= | ![]() |
Out[5]= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
If a graph has multiple edges per vertex-pair on a path, all possibilities are returned:
In[7]:= | ![]() |
Out[7]= | ![]() |
FindPath returns a single path:
In[8]:= | ![]() |
Out[8]= | ![]() |
FindPathEdges returns all edge paths compatible with this:
In[9]:= | ![]() |
Out[9]= | ![]() |
In[10]:= | ![]() |
Out[10]= | ![]() |
Find the self-edges of a vertex:
In[11]:= | ![]() |
Out[11]= | ![]() |
In[12]:= | ![]() |
Out[12]= | ![]() |
Convert vertex paths to edge paths:
In[13]:= | ![]() |
Out[13]= | ![]() |
In[14]:= | ![]() |
Out[14]= | ![]() |
If no edge path exists, an empty list is returned:
In[15]:= | ![]() |
Out[15]= | ![]() |
If the path contains a vertex that does not exist, an error is raised:
In[16]:= | ![]() |
Out[16]= | ![]() |
Wolfram Language 14.0 (January 2024) or above
This work is licensed under a Creative Commons Attribution 4.0 International License