NetworkX の使い方です。
number01.py
#! /usr/bin/python
#
# number01.py
#
# Apr/16/2019
# ------------------------------------------------------------------
import sys
import networkx as nx
# ------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
G = nx.DiGraph() # 有向グラフ (Directed Graph)
data_array = [1,2,3,4,5,6,7,8]
# 指定した閉路上の頂点と辺を追加
G.add_cycle(data_array)
#
nx.nx_agraph.view_pygraphviz(G, prog='fdp')
#
sys.stderr.write("*** 終了 ***\n")
# ------------------------------------------------------------------
ラベルを使う例
label01.py
#! /usr/bin/python
#
# label01.py
#
# Apr/16/2019
# ------------------------------------------------------------------
import sys
import networkx as nx
# ------------------------------------------------------------------
sys.stderr.write("*** 開始 ***\n")
G = nx.DiGraph() # 有向グラフ (Directed Graph)
data_array = ['文久','元治','慶応','明治','大正','昭和','平成','令和']
# 指定した閉路上の頂点と辺を追加
G.add_cycle(data_array)
#
nx.nx_agraph.view_pygraphviz(G, prog='fdp')
#
sys.stderr.write("*** 終了 ***\n")
# ------------------------------------------------------------------
使った NetworkX のバージョン
$ python
Python 3.7.3 (default, Mar 26 2019, 21:43:19)
[GCC 8.2.1 20181127] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import networkx
>>> networkx.__version__
'2.2'