# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Create path graphs between two vertices in a graph where the paths are constructed without consideration of the direction of the edges

Contributed by:
Seth J. Chandler

ResourceFunction["WeakPathGraphs"][ takes a graph | |

ResourceFunction["WeakPathGraphs"][ returns only paths satisfying the length specified by | |

ResourceFunction["WeakPathGraphs"][ finds at most |

The documentation for FindPath provides detailed information on how to use the *kspec* parameter.

One can use all options for Graph in ResourceFunction["WeakPathGraphs"]. Options given to ResourceFunction["WeakPathGraphs"] will take precedence over the option settings from the underlying graph.

An issue in creating weak path graphs is inheritance of options from the underlying graph where the user has not specified option settings. Sometimes it will be desirable to preserve those options, sometimes it will be undesirable, and sometimes preservation of the options will prevent rendering of the ResourceFunction["WeakPathGraphs"].

The "Inherit" and "Disinherit" options give you additional control over this option inheritance. The "Inherit" option lets you specify what options from the underlying graph you wish to keep.

The following settings are supported for "Inherit" or "Disinherit":

Automatic | (default) inherit or disinherit all settings that do not prevent rendering in the output |

All | inherit or disinherit all settings |

None | inherit or disinherit no settings |

{opt_{1},opt_{2},…} | list of Graph option names to inherit or disinherit |

The "Disinherit" option overrides option inheritance decisions made by the "Inherit" option. Thus, if one wanted to use All or Automatic to preserve most of the options but not VertexShapeFunction, one might use "Inherit"→Automatic, "Disinherit"→{VertexShapeFunction} as option settings.

Note, however: any options set directly from within ResourceFunction["WeakPathGraphs"] take precedence over any option settings in the underlying graph.

Find a weak path graph for a simple directed graph:

In[1]:= |

Out[1]= |

Take a graph and find all paths between "sodium" and "sbp" assuming the graph was undirected, but preserve the direction of the original edges in the resulting "weak path graph":

In[2]:= |

Out[2]= |

In[3]:= |

Out[3]= |

WeakPathGraphs works with undirected graphs:

In[4]:= |

Out[4]= |

Same idea but with different options to improve rendering:

In[5]:= |

Out[5]= |

Directed graphs:

In[6]:= |

Out[6]= |

Multigraphs:

In[7]:= |

Out[7]= |

Mixed graphs:

In[8]:= |

Out[8]= |

Weighted graphs:

In[9]:= |

Out[9]= |

Weighted graphs with EdgeWeight disinherited:

In[10]:= |

Out[10]= |

Small graphs:

In[11]:= |

Out[11]= |

By default, the weak path graphs created by this function inherit options from the underlying graph. One can use any option available to Graph to override those options or to add other options:

In[12]:= |

Out[12]= |

In[13]:= |

Out[13]= |

One can also choose to prevent inheritance altogether:

In[14]:= |

Out[14]= |

One can also choose to inherit only listed options:

In[15]:= |

Out[15]= |

And one can combine inheritance of listed options with additional options:

In[16]:= |

Out[16]= |

Instead of a list of options you want inherited, you can specify options you want disinherited:

In[17]:= |

Out[17]= |

In[18]:= |

Out[18]= |

One can show the weak paths in the context of the original graph:

In[19]:= |

Out[19]= |

Find links between blogs that exist only when the orientation of the graph is disregarded, but show the orientation of the edges on the path:

In[20]:= |

Out[20]= |

There are no conventional paths:

In[21]:= |

Out[21]= |

There are paths if orientation is disregarded:

In[22]:= |

Out[22]= |

Find "backdoor" paths as well as directed paths in a causal network:

In[23]:= |

In[24]:= |

Out[24]= |

Show that deleting all incoming edges to attention disorder means that the only paths remaining between lung cancer and car accident are direct causal chains:

In[25]:= |

Out[25]= |

Characterize all the "triples" on direction tolerant paths between two vertices as "chains," "forks" or "colliders":

In[26]:= |

In[27]:= |

Out[27]= |

Determine whether two nodes of a graph are "*d*-separated" from each other by seeing if there are colliders on all the weak paths between two vertices:

In[28]:= |

Out[28]= |

In[29]:= |

In[30]:= |

Out[30]= |

- 1.1.1 – 23 June 2022
- 1.1.0 – 13 July 2021

This work is licensed under a Creative Commons Attribution 4.0 International License