Function Repository Resource:

SequenceGraph

Source Notebook

Create a graph from a data sequence

Contributed by: Daniel de Souza Carvalho

ResourceFunction["SequenceGraph"][list]

creates a graph connecting adjacent entries of list.

Details and Options

In ResourceFunction["SequenceGraph"][list], list can contain numbers, strings or symbolic values.
ResourceFunction["SequenceGraph"] accepts the same options as Graph.

Examples

Basic Examples (1) 

Plot a simple series of numbers:

In[1]:=
ResourceFunction["SequenceGraph"][{1, 2, 2, 1, 1, 1, 2, 5, 5, 5}]
Out[1]=

Scope (5) 

SequenceGraph accepts string elements as well as any options accepted by Graph:

In[2]:=
ResourceFunction[
 "SequenceGraph"][{"a", "a", "a", "b", "b", "c", "c", "c", "d", "c", "d", "c", "e", "c"}, VertexLabels -> "Name"]
Out[2]=

SequenceGraph accepts a series of symbolic values:

In[3]:=
ResourceFunction[
 "SequenceGraph"][{a, a, a, a, b, c, d, e, e, e, i, j, k, i}, VertexLabels -> "Name", GraphLayout -> "CircularEmbedding"]
Out[3]=

Plot a series created by a range of data:

In[4]:=
ResourceFunction["SequenceGraph"][Range[10], VertexLabels -> "Name"]
Out[4]=

Plot the digits of π:

In[5]:=
RealDigits[N[Pi, 100]][[1]]
Out[5]=
In[6]:=
ResourceFunction["SequenceGraph"][%, DirectedEdges -> True]
Out[7]=

Plot the digits of :

In[8]:=
RealDigits[N[E, 100]][[1]]
Out[8]=
In[9]:=
ResourceFunction["SequenceGraph"][%]
Out[10]=

Applications (3) 

Analyze the dynamical behavior of a class-4 cellular automaton by the sum of black cells of each step, and view as a graph:

In[11]:=
ca = CellularAutomaton[110, RandomInteger[1, 100], 100];
ArrayPlot[ca, Frame -> None]
Out[12]=
In[13]:=
ResourceFunction["SequenceGraph"][Total[Transpose[ca]]]
Out[13]=

Analyze the dynamical behavior of a class-2 cellular automaton by the sum of black cells of each step, and view as a graph:

In[14]:=
ca = CellularAutomaton[220, RandomInteger[1, 20], 20];
ArrayPlot[ca, Frame -> None]
Out[15]=
In[16]:=
ResourceFunction["SequenceGraph"][Total[Transpose[ca]], DirectedEdges -> True]
Out[16]=

Plot the sequence of words in a book:

In[17]:=
ResourceFunction["SequenceGraph"][
 StringSplit[DeleteStopwords[ResourceData["Alice in Wonderland"]], RegularExpression["\\W+"]]]
Out[17]=

Publisher

Daniel de Souza Carvalho

Version History

  • 1.0.0 – 24 September 2019

Source Metadata

License Information