Wolfram Research

Function Repository Resource:

ConnectedWolframModelQ

Source Notebook

Determine whether a Wolfram model rule is left-connected

Contributed by: Max Piskunov

ResourceFunction["ConnectedWolframModelQ"][rule]

yields True if the left-hand side of the rule is connected, and the right-hand side is connected to the left-hand side.

ResourceFunction["ConnectedWolframModelQ"][rule,All]

yields True if both sides of the rule are separately connected, and also connected to each other.

Details and Options

ResourceFunction["ConnectedWolframModelQ"][rule] yields True if the rule is local (left-hand side is connected). It may produce disconnected components, which it would not do if the right-hand side was connected to the left-hand side.
ResourceFunction["ConnectedWolframModelQ"][rule,All] also tests whether the right-hand side is connected. The rule can still however produce disconnected components even in ResourceFunction["ConnectedWolframModelQ"][rule,All].

Examples

Basic Examples (2) 

An example of a connected rule:

In[1]:=
ResourceFunction["ConnectedWolframModelQ"][{{1, 2}} -> {{2, 3}}]
Out[1]=

An example of a disconnected rule:

In[2]:=
ResourceFunction["ConnectedWolframModelQ"][{{1, 2}} -> {{3, 4}}]
Out[2]=

Scope (6) 

Multiple rules are supported:

In[3]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{{1, 2}} -> {{3, 4}}, {{1, 2}} -> {{1, 2}}}]
Out[3]=
In[4]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{{1, 2}} -> {{2, 3}}, {{1, 2}} -> {{1, 2}}}]
Out[4]=

Unary edges are supported:

In[5]:=
ResourceFunction["ConnectedWolframModelQ"][{{1}} -> {{2}}]
Out[5]=
In[6]:=
ResourceFunction["ConnectedWolframModelQ"][{{1}} -> {{1}}]
Out[6]=
In[7]:=
ResourceFunction["ConnectedWolframModelQ"][{{1}, {2}} -> {{1}}]
Out[7]=

By default, the right-hand side is allowed to be disconnected:

In[8]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{1, 5}} -> {{2, 3}, {4, 5}}]
Out[8]=

Left- and right- hand sides should be connected to each other:

In[9]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{1, 3}} -> {{1, 2}, {3, 4}}]
Out[9]=

While the right-hand side can be disconnected, each piece must be connected to the left-hand side:

In[10]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{1, 2}} -> {{1, 2}, {3, 4}}]
Out[10]=

One can also require the right-hand side to be connected separately:

In[11]:=
ResourceFunction[
 "ConnectedWolframModelQ"][{{1, 3}} -> {{1, 2}, {3, 4}}, All]
Out[11]=

Resource History

Related Resources

License Information