Wolfram Research

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

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

Examples

Basic Examples

Plot a simple series of numbers:

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

SequenceGraph accepts string elements and optional parameters from 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]]
ResourceFunction["SequenceGraph"][%, DirectedEdges -> True]
Out[5]=
Out[6]=

Plot the digits of ⅇ:

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

Application

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[9]:=
ca = CellularAutomaton[110, RandomInteger[1, 100], 100];
ArrayPlot[ca, Frame -> None]
Out[10]=
In[11]:=
ResourceFunction["SequenceGraph"][Total[Transpose[ca]]]
Out[11]=

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[12]:=
ca = CellularAutomaton[220, RandomInteger[1, 20], 20];
ArrayPlot[ca, Frame -> None]
Out[13]=
In[14]:=
ResourceFunction["SequenceGraph"][Total[Transpose[ca]], DirectedEdges -> True]
Out[14]=

Plot the sequence of words in a book:

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

Resource History

Source Metadata

License Information