Function Repository Resource:

CycleAdd

Source Notebook

Add a cycle graph to an existing graph

Contributed by: Alejandra Ortiz Duran

ResourceFunction["CycleAdd"][g,v]

adds a cycle graph, generated from the specified vertices v, to the graph g.

Details and Options

A cycle will be constructed from the nodes v and added to the graph.
ResourceFunction["CycleAdd"] generates a Graph object.
ResourceFunction["CycleAdd"] takes the same options as Graph.
ResourceFunction["CycleAdd"] works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

Examples

Basic Examples (1) 

Add a cycle to a graph:

In[1]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8}, {Null, 
SparseArray[
         Automatic, {8, 8}, 0, {1, {{0, 2, 4, 6, 8, 10, 12, 14, 16}, {{2}, {8}, {1}, {
            3}, {2}, {4}, {3}, {5}, {4}, {6}, {5}, {7}, {6}, {8}, {
            1}, {7}}}, Pattern}]}, {GraphLayout -> "CircularEmbedding", ImageSize -> Tiny, PlotTheme -> "Detailed"}]]}, 
TagBox[GraphicsGroupBox[{
{Hue[0.6, 0.7, 0.5], Opacity[0.7], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$1"],
RowBox[{"1", "\[UndirectedEdge]", "2"}]],
Annotation[#, 
UndirectedEdge[1, 2], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$2"],
RowBox[{"1", "\[UndirectedEdge]", "8"}]],
Annotation[#, 
UndirectedEdge[1, 8], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$3"],
RowBox[{"2", "\[UndirectedEdge]", "3"}]],
Annotation[#, 
UndirectedEdge[2, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$4"],
RowBox[{"3", "\[UndirectedEdge]", "4"}]],
Annotation[#, 
UndirectedEdge[3, 4], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$5"],
RowBox[{"4", "\[UndirectedEdge]", "5"}]],
Annotation[#, 
UndirectedEdge[4, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$6"],
RowBox[{"5", "\[UndirectedEdge]", "6"}]],
Annotation[#, 
UndirectedEdge[5, 6], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$7"],
RowBox[{"6", "\[UndirectedEdge]", "7"}]],
Annotation[#, 
UndirectedEdge[6, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$8"],
RowBox[{"7", "\[UndirectedEdge]", "8"}]],
Annotation[#, 
UndirectedEdge[7, 8], "Tooltip"]& ]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[{
TagBox[DiskBox[{-0.707106781186548, 0.7071067811865482}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$1"], InsetBox["1", Dynamic[
             DynamicLocation[
               "VertexID$1", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}]) ((
                 1 + {-0.9999999999999997, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$1", Automatic, {Left, Bottom}]) {-0.9999999999999997, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$1"], 
TagBox[{
TagBox[DiskBox[{-7.044813998280222*^-16, 1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$2"], InsetBox["2", Dynamic[
             DynamicLocation[
               "VertexID$2", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}]) ((
                 1 + {-7.044813998280222*^-16, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}] + (
                 DynamicLocation[ "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$2", Automatic, {Left, Bottom}]) {-7.044813998280222*^-16, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$2"], 
TagBox[{
TagBox[DiskBox[{0.707106781186547, 0.7071067811865467}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$3"], InsetBox["3", Dynamic[
             DynamicLocation[
               "VertexID$3", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}]) ((
                 1 + {1., 0.9999999999999996})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$3", Automatic, {Left, Bottom}]) {1., 0.9999999999999996}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$3"], 
TagBox[{
TagBox[DiskBox[{1., -1.133107779529596*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$4"], InsetBox["4", Dynamic[
             DynamicLocation[
               "VertexID$4", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}]) ((
                 1 + {1., -1.133107779529596*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$4", Automatic, {Left, Bottom}]) {
                 1., -1.133107779529596*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$4"], 
TagBox[{
TagBox[DiskBox[{0.7071067811865481, -0.7071067811865483}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$5"], InsetBox["5", Dynamic[
             DynamicLocation[
               "VertexID$5", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$5", Automatic, {Left, Bottom}]) ((
                 1 + {0.9999999999999997, -1.})/2)], (-2) Dynamic[
              DynamicLocation[ "VertexID$5", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$5", Automatic, {Left, Bottom}]) {
                 0.9999999999999997, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$5"], 
TagBox[{
TagBox[DiskBox[{6.049014748177263*^-16, -1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$6"], InsetBox["6", Dynamic[
             DynamicLocation[
               "VertexID$6", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}]) ((
                 1 + {6.049014748177263*^-16, -1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$6", Automatic, {Left, Bottom}]) {
                 6.049014748177263*^-16, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$6"], 
TagBox[{
TagBox[DiskBox[{-0.707106781186547, -0.7071067811865468}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$7"], InsetBox["7", Dynamic[
             DynamicLocation[
               "VertexID$7", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}]) ((
                 1 + {-1., -0.9999999999999997})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$7", Automatic, {Left, Bottom}]) {-1., -0.9999999999999997}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$7"], 
TagBox[{
TagBox[DiskBox[{-1., 1.0106430996148606`*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$8"], InsetBox["8", Dynamic[
             DynamicLocation[
               "VertexID$8", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}]) ((
                 1 + {-1., 1.0106430996148606`*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$8", Automatic, {Left, Bottom}]) {-1., 1.0106430996148606`*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$8"]}}],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None,
ImageSize->{107.52734375, 107.3570204375}]\), {8, 9, 10, 11, 12, 13, 14}, PlotTheme -> "Detailed"]
Out[1]=

Scope (7) 

Works with undirected graphs:

In[2]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8}, {Null, 
SparseArray[
         Automatic, {8, 8}, 0, {1, {{0, 2, 4, 6, 8, 10, 12, 14, 16}, {{2}, {8}, {1}, {
            3}, {2}, {4}, {3}, {5}, {4}, {6}, {5}, {7}, {6}, {8}, {
            1}, {7}}}, Pattern}]}, {GraphLayout -> "CircularEmbedding", ImageSize -> Tiny, PlotTheme -> "Detailed"}]]}, 
TagBox[GraphicsGroupBox[{
{Hue[0.6, 0.7, 0.5], Opacity[0.7], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$1"],
RowBox[{"1", "\[UndirectedEdge]", "2"}]],
Annotation[#, 
UndirectedEdge[1, 2], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$2"],
RowBox[{"1", "\[UndirectedEdge]", "8"}]],
Annotation[#, 
UndirectedEdge[1, 8], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$3"],
RowBox[{"2", "\[UndirectedEdge]", "3"}]],
Annotation[#, 
UndirectedEdge[2, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$4"],
RowBox[{"3", "\[UndirectedEdge]", "4"}]],
Annotation[#, 
UndirectedEdge[3, 4], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$5"],
RowBox[{"4", "\[UndirectedEdge]", "5"}]],
Annotation[#, 
UndirectedEdge[4, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$6"],
RowBox[{"5", "\[UndirectedEdge]", "6"}]],
Annotation[#, 
UndirectedEdge[5, 6], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$7"],
RowBox[{"6", "\[UndirectedEdge]", "7"}]],
Annotation[#, 
UndirectedEdge[6, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$8"],
RowBox[{"7", "\[UndirectedEdge]", "8"}]],
Annotation[#, 
UndirectedEdge[7, 8], "Tooltip"]& ]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[{
TagBox[DiskBox[{-0.707106781186548, 0.7071067811865482}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$1"], InsetBox["1", Dynamic[
             DynamicLocation[
               "VertexID$1", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}]) ((
                 1 + {-0.9999999999999997, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$1", Automatic, {Left, Bottom}]) {-0.9999999999999997, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$1"], 
TagBox[{
TagBox[DiskBox[{-7.044813998280222*^-16, 1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$2"], InsetBox["2", Dynamic[
             DynamicLocation[
               "VertexID$2", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}]) ((
                 1 + {-7.044813998280222*^-16, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}] + (
                 DynamicLocation[ "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$2", Automatic, {Left, Bottom}]) {-7.044813998280222*^-16, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$2"], 
TagBox[{
TagBox[DiskBox[{0.707106781186547, 0.7071067811865467}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$3"], InsetBox["3", Dynamic[
             DynamicLocation[
               "VertexID$3", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}]) ((
                 1 + {1., 0.9999999999999996})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$3", Automatic, {Left, Bottom}]) {1., 0.9999999999999996}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$3"], 
TagBox[{
TagBox[DiskBox[{1., -1.133107779529596*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$4"], InsetBox["4", Dynamic[
             DynamicLocation[
               "VertexID$4", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}]) ((
                 1 + {1., -1.133107779529596*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$4", Automatic, {Left, Bottom}]) {
                 1., -1.133107779529596*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$4"], 
TagBox[{
TagBox[DiskBox[{0.7071067811865481, -0.7071067811865483}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$5"], InsetBox["5", Dynamic[
             DynamicLocation[
               "VertexID$5", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$5", Automatic, {Left, Bottom}]) ((
                 1 + {0.9999999999999997, -1.})/2)], (-2) Dynamic[
              DynamicLocation[ "VertexID$5", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$5", Automatic, {Left, Bottom}]) {
                 0.9999999999999997, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$5"], 
TagBox[{
TagBox[DiskBox[{6.049014748177263*^-16, -1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$6"], InsetBox["6", Dynamic[
             DynamicLocation[
               "VertexID$6", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}]) ((
                 1 + {6.049014748177263*^-16, -1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$6", Automatic, {Left, Bottom}]) {
                 6.049014748177263*^-16, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$6"], 
TagBox[{
TagBox[DiskBox[{-0.707106781186547, -0.7071067811865468}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$7"], InsetBox["7", Dynamic[
             DynamicLocation[
               "VertexID$7", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}]) ((
                 1 + {-1., -0.9999999999999997})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$7", Automatic, {Left, Bottom}]) {-1., -0.9999999999999997}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$7"], 
TagBox[{
TagBox[DiskBox[{-1., 1.0106430996148606`*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$8"], InsetBox["8", Dynamic[
             DynamicLocation[
               "VertexID$8", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}]) ((
                 1 + {-1., 1.0106430996148606`*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$8", Automatic, {Left, Bottom}]) {-1., 1.0106430996148606`*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$8"]}}],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None,
ImageSize->{107.52734375, 107.3570204375}]\), {8, 9, 10, 11, 12, 13, 14}, PlotTheme -> "Detailed"]
Out[2]=

Directed graphs:

In[3]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8}, {
SparseArray[
         Automatic, {8, 8}, 0, {1, {{0, 1, 2, 3, 4, 5, 6, 7, 8}, {{2}, {3}, {4}, {5}, {
            6}, {7}, {8}, {1}}}, Pattern}], Null}, {GraphLayout -> "CircularEmbedding", ImageSize -> Tiny, PlotTheme -> "Detailed"}]]}, 
TagBox[GraphicsGroupBox[{
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[Medium], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$1"],
RowBox[{"1", "\[DirectedEdge]", "2"}]],
Annotation[#, 
DirectedEdge[1, 2], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$2"],
RowBox[{"2", "\[DirectedEdge]", "3"}]],
Annotation[#, 
DirectedEdge[2, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$3"],
RowBox[{"3", "\[DirectedEdge]", "4"}]],
Annotation[#, 
DirectedEdge[3, 4], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$4"],
RowBox[{"4", "\[DirectedEdge]", "5"}]],
Annotation[#, 
DirectedEdge[4, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$5"],
RowBox[{"5", "\[DirectedEdge]", "6"}]],
Annotation[#, 
DirectedEdge[5, 6], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$6"],
RowBox[{"6", "\[DirectedEdge]", "7"}]],
Annotation[#, 
DirectedEdge[6, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$7"],
RowBox[{"7", "\[DirectedEdge]", "8"}]],
Annotation[#, 
DirectedEdge[7, 8], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$8"],
RowBox[{"8", "\[DirectedEdge]", "1"}]],
Annotation[#, 
DirectedEdge[8, 1], "Tooltip"]& ]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[{
TagBox[DiskBox[{-0.707106781186548, 0.7071067811865482}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$1"], InsetBox["1", Dynamic[
             DynamicLocation[
               "VertexID$1", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}]) ((
                 1 + {-0.9999999999999997, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$1", Automatic, {Left, Bottom}]) {-0.9999999999999997, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$1"], 
TagBox[{
TagBox[DiskBox[{-1., 1.0106430996148606`*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$2"], InsetBox["2", Dynamic[
             DynamicLocation[
               "VertexID$2", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}]) ((
                 1 + {-1., 1.0106430996148606`*^-15})/2)], (-2)
               Dynamic[
              DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}] + (
                 DynamicLocation[ "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$2", Automatic, {Left, Bottom}]) {-1., 1.0106430996148606`*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$2"], 
TagBox[{
TagBox[DiskBox[{-0.707106781186547, -0.7071067811865468}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$3"], InsetBox["3", Dynamic[
             DynamicLocation[
               "VertexID$3", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}]) ((
                 1 + {-1., -0.9999999999999997})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$3", Automatic, {Left, Bottom}]) {-1., -0.9999999999999997}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$3"], 
TagBox[{
TagBox[DiskBox[{6.049014748177263*^-16, -1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$4"], InsetBox["4", Dynamic[
             DynamicLocation[
               "VertexID$4", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}]) ((
                 1 + {6.049014748177263*^-16, -1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$4", Automatic, {Left, Bottom}]) {
                 6.049014748177263*^-16, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$4"], 
TagBox[{
TagBox[DiskBox[{0.7071067811865481, -0.7071067811865483}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$5"], InsetBox["5", Dynamic[
             DynamicLocation[
               "VertexID$5", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$5", Automatic, {Left, Bottom}]) ((
                 1 + {0.9999999999999997, -1.})/2)], (-2) Dynamic[
              DynamicLocation[ "VertexID$5", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$5", Automatic, {Left, Bottom}]) {
                 0.9999999999999997, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$5"], 
TagBox[{
TagBox[DiskBox[{1., -1.133107779529596*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$6"], InsetBox["6", Dynamic[
             DynamicLocation[
               "VertexID$6", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}]) ((
                 1 + {1., -1.133107779529596*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$6", Automatic, {Left, Bottom}]) {
                 1., -1.133107779529596*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$6"], 
TagBox[{
TagBox[DiskBox[{0.707106781186547, 0.7071067811865467}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$7"], InsetBox["7", Dynamic[
             DynamicLocation[
               "VertexID$7", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}]) ((
                 1 + {1., 0.9999999999999996})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$7", Automatic, {Left, Bottom}]) {1., 0.9999999999999996}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$7"], 
TagBox[{
TagBox[DiskBox[{-7.044813998280222*^-16, 1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$8"], InsetBox["8", Dynamic[
             DynamicLocation[
               "VertexID$8", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}]) ((
                 1 + {-7.044813998280222*^-16, 1.})/2)], (-2) Dynamic[ DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$8", Automatic, {Left, Bottom}]) {-7.044813998280222*^-16, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$8"]}}],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None,
ImageSize->{116.47265625, 116.2881635625}]\), {8, 9, 10, 11, 12, 13, 14}, PlotTheme -> "Detailed", DirectedEdges -> True]
Out[3]=

Multigraphs:

In[4]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, {{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
         3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}, {3, 1}, {3, 6}, {3, 4}}}]]}, 
TagBox[GraphicsGroupBox[GraphicsComplexBox[CompressedData["
1:eJw9k3s01Akfxqcwonq7uB6taxaVWolk2Xmm1q2OTsLGxiurGrcuWsu+eUsj
irTruosiGbxviUZuNQb9EDNyp6salxAT4TdjvMQM7+w573m/53zP9zznec55
/vl+DAPOu59eTaFQGPL96ybfNGas5FLo0SZOmyeyG6HE//uwteQLIj0eeG+b
n8Gy5saM77JJUP43JrnCdpu7JDbYhsblHBoG1StYW6LTj+M9tHj16Zn/5wRi
dz2V8kaM12kq2qatYKjkm5TGn5/A4MJJeo3xCvJub7ExM6zE86JZ7+7KZQgH
c7Y9My5D99mfU7kHlpGidWKxdLkEwy2bI+s6ZWButkyZOXUfSUGpFbo/yuAf
Lghcji6E9Keb0wbDUhgEOvvtOMLCPqsDt9eHSFEfdWOhnH0HJwJ36P3eOAd/
itf9F/13iKOFne4PDs5ho/3Qrw4P84jX4pMF6JYg5Vf9DP0yFvH1McbsH8ck
ICWdHh++sIipHmtXsWAWj7Yv5vjFs4iS3LDyuydnMVTlQXv/Yx5B/ebI0uiE
GPTfDKPURnMID8ev8lXC5Tr5zDuN/EyiVWhfb8lYQRAnvcM8pRmaKyqBXtPL
WOOdGHNmHw8XkoWlORHLWFB7/8G/nAcL362ah6QymJfFVTfIeFh4Iz5376oM
nBHbwAAdPpzs5p5K18gQoNg5v3sNH+03EjekJUvBtKZZ2PF5eMrb6VCqKUUC
9Wh8oRcPH79otuw6PweX6WCGaXsdDNs7wrfMSxB0KyiCllKLpGY+W48pgYta
Lum5wIXdaafP0aoScL4P9/VVqsbh+rHumIxZmDX4ml7iPIZn3GmVM8azoJyd
WdyoVglp7ZxhTKUYbuVhU8WaZbAOO+Cn4CyGAb3abGtiMW4YlTrrOpIoO0vL
jJlioyP6is5bCxJxXVYSSlAFKDKjQyx9Eof5fRrswCcQTbcqx24icXyVslZI
eA22DDJKr1FJGNjFc7sSCCxon7x2QjaDDI6TEre3Ab8ce9i6VjIDu72ZI+Ej
z7D+VGClhmgGDrTyUN+5ZqTvZTs5yH2/sV3U5pw+5P6z7M+H8r+uueJEVPzr
HZTXRRpxKSSijF5tpLDfQ/vaQcfna0g0CM5Hr68SQO8Z/+yKGgnngSgXOrcf
22rTFn4wIvGPKv8WWe0Atn8ODGraQ6LPbGt7Se0gjNRNQ+kuJMa58QvHfYeg
yOqZtxKTyB62eao9ysZSS8riI6oIxl93iC0CKiBdOB2iry1Ckfj1qin/J1AW
W8xFmIhw5si5VSOhNfibRaluyW4Rrv5wexubSUCv6Cq9xlYEt7uryQudDTg2
r5+VSxOha1Q/XXXwGQS3WPCgi5CgdURJSDZDT6E5YWK/CBQPWW/i7T5MquRf
Pi/3ld6oal0peIciM+e8ZjsR3mrsoQqK30P1dWrFzB4RfAqsdJQqBLDi7fQR
m4nQUaYe68fphwnnlfZLHXk/xT/2cM0AvPdedLmjIsJ+2vO2fTWDyE47uMV7
joSN+3xIk88QkncXbHJMmAKFP22fezmTUF/fVvgp6zPoVhoX7z/OIa4/D+jt
vTcJ/7fr/pyl5RHBbUveyVUTcn7+05UUxCKKdm8vYjd+AiXFnhPxhkXIDmSm
1HcJkedkXMi4ySIyngpGPfvHERZunJMUl0f4XfTZtTQ5BoOmSObm+DuE+aoQ
20XHF2AWpw1955qLrEjL2ARGD5ie3CbnPBYEKtImoWYXHmV7ZX3VW4ibjfl0
dmgbwgZ0LKur72Pi6Me03zv4YJpTOR2eDxFmlKpWTGvCW5cWqptbGThjqupG
DfXwDo7mUA9XwvzQFyizuUjgu+/g5T5BlaKhA3doCkz7fxtlyXlw/UX3niV1
CmGXTOPWapXB76NdYLfJZ5A5/daNcp6u9DH4Wt9PgtmV719c/Rhel+ezk30m
kBCZVWCtXI3YHR8W68M+QagVRSosccEWX5/YGyvEpRqX49PptTi1M3RDdPo4
hr6NaVrdUweb4BtLK3+8hH/bT+cmA3hoHbie5FreC+4G32bzFzwsvtpkE9HR
jThFX/6wOh/7RW/WWnZ1QKAZ8NuYqVwnprqWKrTiQYZbr/k6Pl6mzjFY3/Ig
NstQ4DXwkBHrqesU2YiAWxE7B1x48B4Zf/HoQh24beTHWlYz/gsAwTVQ
"], {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[0.], ArrowBox[{1, 2}, 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{1, {
              1.5816749614414627`, -0.09828324319646761}, 3}], 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{1, {1.5338611410187128`, 0.24366637128910326`}, 3}], 0.023238294114515057`], ArrowBox[{1, 4}, 0.023238294114515057`], ArrowBox[{2, 3}, 0.023238294114515057`], ArrowBox[{2, 4}, 0.023238294114515057`], ArrowBox[{2, 5}, 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{3, {0.9443904327127498, 0.2859635975131389}, 4}], 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{3, {1.1323816721298898`, 0.28564423885786105`}, 4}], 0.023238294114515057`], ArrowBox[{3, 5}, 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{3, {
              0.4949323428614221, -0.09764403070558117}, 6}], 0.023238294114515057`], ArrowBox[
            BezierCurveBox[{3, {0.5429681871745602, 0.24370224661615855`}, 6}], 0.023238294114515057`], ArrowBox[{4, 5}, 0.023238294114515057`], ArrowBox[{4, 6}, 0.023238294114515057`], ArrowBox[{5, 6}, 0.023238294114515057`]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, PlotTheme -> "Detailed"]
Out[4]=

Mixed graphs:

In[5]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{2, 1, 3, 4, 5, 6}, {{{1, 2}, {4, 2}, {4, 1}, {1, 5}, {5, 4}, {4, 6}, {6, 5}}, {{3, 2}, {3, 1}, {3, 4}, {5, 3}, {6, 3}}}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{0.4551850578911978, 0.9981525468616489}, {0., 0.14598126079677531`}, {
         1.0389677124195058`, 0.}, {1.039724112924609, 0.5701570146988366}, {1.6227200863036675`, 0.998361077743834}, {2.078219876386564, 0.1459015541744016}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[Medium], 
{Arrowheads[0.], ArrowBox[{1, 3}, 0.02324298839356595]}, ArrowBox[{1, 2}, 0.02324298839356595], ArrowBox[{1, 5}, 0.02324298839356595], 
{Arrowheads[0.], ArrowBox[{2, 3}, 0.02324298839356595]}, 
{Arrowheads[0.], ArrowBox[{3, 4}, 0.02324298839356595]}, 
{Arrowheads[0.], ArrowBox[{3, 5}, 0.02324298839356595]}, 
{Arrowheads[0.], ArrowBox[{3, 6}, 0.02324298839356595]}, ArrowBox[{4, 1}, 0.02324298839356595], ArrowBox[{4, 2}, 0.02324298839356595], ArrowBox[{4, 6}, 0.02324298839356595], ArrowBox[{5, 4}, 0.02324298839356595], ArrowBox[{6, 5}, 0.02324298839356595]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.02324298839356595], DiskBox[2, 0.02324298839356595], DiskBox[3, 0.02324298839356595], DiskBox[4, 0.02324298839356595], DiskBox[5, 0.02324298839356595], DiskBox[6, 0.02324298839356595]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10}, PlotTheme -> "Detailed"]
Out[5]=

And rules to specify the graph:

In[6]:=
ResourceFunction["CycleAdd"][
 Graph@{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}, {3, 7, 8, 9, 10, 11}, VertexLabels -> Automatic]
Out[6]=

Use already existing vertices to form the cycle:

In[7]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8}, {
SparseArray[
         Automatic, {8, 8}, 0, {1, {{0, 1, 2, 3, 4, 5, 6, 7, 8}, {{2}, {3}, {4}, {5}, {
            6}, {7}, {8}, {1}}}, Pattern}], Null}, {GraphLayout -> "CircularEmbedding", ImageSize -> Tiny, PlotTheme -> "Detailed"}]]}, 
TagBox[GraphicsGroupBox[{
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[Medium], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$1"],
RowBox[{"1", "\[DirectedEdge]", "2"}]],
Annotation[#, 
DirectedEdge[1, 2], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$2"],
RowBox[{"2", "\[DirectedEdge]", "3"}]],
Annotation[#, 
DirectedEdge[2, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$3"],
RowBox[{"3", "\[DirectedEdge]", "4"}]],
Annotation[#, 
DirectedEdge[3, 4], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$4"],
RowBox[{"4", "\[DirectedEdge]", "5"}]],
Annotation[#, 
DirectedEdge[4, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$5"],
RowBox[{"5", "\[DirectedEdge]", "6"}]],
Annotation[#, 
DirectedEdge[5, 6], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$6"],
RowBox[{"6", "\[DirectedEdge]", "7"}]],
Annotation[#, 
DirectedEdge[6, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$7"],
RowBox[{"7", "\[DirectedEdge]", "8"}]],
Annotation[#, 
DirectedEdge[7, 8], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$8"],
RowBox[{"8", "\[DirectedEdge]", "1"}]],
Annotation[#, 
DirectedEdge[8, 1], "Tooltip"]& ]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[{
TagBox[DiskBox[{-0.707106781186548, 0.7071067811865482}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$1"], InsetBox["1", Dynamic[
             DynamicLocation[
               "VertexID$1", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}]) ((
                 1 + {-0.9999999999999997, 1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$1", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$1", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$1", Automatic, {Left, Bottom}]) {-0.9999999999999997, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$1"], 
TagBox[{
TagBox[DiskBox[{-1., 1.0106430996148606`*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$2"], InsetBox["2", Dynamic[
             DynamicLocation[
               "VertexID$2", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}]) ((
                 1 + {-1., 1.0106430996148606`*^-15})/2)], (-2)
               Dynamic[
              DynamicLocation[
                "VertexID$2", Automatic, {Left, Bottom}] + (
                 DynamicLocation[ "VertexID$2", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$2", Automatic, {Left, Bottom}]) {-1., 1.0106430996148606`*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$2"], 
TagBox[{
TagBox[DiskBox[{-0.707106781186547, -0.7071067811865468}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$3"], InsetBox["3", Dynamic[
             DynamicLocation[
               "VertexID$3", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}]) ((
                 1 + {-1., -0.9999999999999997})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$3", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$3", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$3", Automatic, {Left, Bottom}]) {-1., -0.9999999999999997}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$3"], 
TagBox[{
TagBox[DiskBox[{6.049014748177263*^-16, -1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$4"], InsetBox["4", Dynamic[
             DynamicLocation[
               "VertexID$4", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}]) ((
                 1 + {6.049014748177263*^-16, -1.})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$4", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$4", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$4", Automatic, {Left, Bottom}]) {
                 6.049014748177263*^-16, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$4"], 
TagBox[{
TagBox[DiskBox[{0.7071067811865481, -0.7071067811865483}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$5"], InsetBox["5", Dynamic[
             DynamicLocation[
               "VertexID$5", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$5", Automatic, {Left, Bottom}]) ((
                 1 + {0.9999999999999997, -1.})/2)], (-2) Dynamic[
              DynamicLocation[ "VertexID$5", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$5", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$5", Automatic, {Left, Bottom}]) {
                 0.9999999999999997, -1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$5"], 
TagBox[{
TagBox[DiskBox[{1., -1.133107779529596*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$6"], InsetBox["6", Dynamic[
             DynamicLocation[
               "VertexID$6", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}]) ((
                 1 + {1., -1.133107779529596*^-15})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$6", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$6", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$6", Automatic, {Left, Bottom}]) {
                 1., -1.133107779529596*^-15}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$6"], 
TagBox[{
TagBox[DiskBox[{0.707106781186547, 0.7071067811865467}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$7"], InsetBox["7", Dynamic[
             DynamicLocation[
               "VertexID$7", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}]) ((
                 1 + {1., 0.9999999999999996})/2)], (-2) Dynamic[
              DynamicLocation[
                "VertexID$7", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$7", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$7", Automatic, {Left, Bottom}]) {1., 0.9999999999999996}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$7"], 
TagBox[{
TagBox[DiskBox[{-7.044813998280222*^-16, 1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$8"], InsetBox["8", Dynamic[
             DynamicLocation[
               "VertexID$8", Automatic, {Left, Bottom}] + (
                DynamicLocation[
                 "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}]) ((
                 1 + {-7.044813998280222*^-16, 1.})/2)], (-2) Dynamic[ DynamicLocation[
                "VertexID$8", Automatic, {Left, Bottom}] + (
                 DynamicLocation[
                  "VertexID$8", Automatic, {Right, Top}] - DynamicLocation[
                 "VertexID$8", Automatic, {Left, Bottom}]) {-7.044813998280222*^-16, 1.}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$8"]}}],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None,
ImageSize->{113.421875, 113.24221475}]\), {3, 5, 7, 1}, PlotTheme -> "Detailed"]
In[8]:=
\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8}, {{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {
        8, 1}}, {{3, 5}, {3, 1}, {5, 7}, {7, 1}}}, {PlotTheme -> "Detailed", VertexCoordinates -> {{-0.707106781186548, 0.7071067811865482}, {-1., 1.0106430996148606`*^-15}, {-0.707106781186547, -0.7071067811865468}, {6.049014748177263*^-16, -1.}, {
         0.7071067811865481, -0.7071067811865483}, {
         1., -1.133107779529596*^-15}, {0.707106781186547, 0.7071067811865467}, {-7.044813998280222*^-16, 1.}}}]]}, 
TagBox[GraphicsGroupBox[{
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[Medium], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$1"],
RowBox[{"1", "\[UndirectedEdge]", "3"}]],
Annotation[#, 
UndirectedEdge[1, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$2"],
RowBox[{"1", "\[UndirectedEdge]", "7"}]],
Annotation[#, 
UndirectedEdge[1, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$3"],
RowBox[{"1", "\[DirectedEdge]", "2"}]],
Annotation[#, 
DirectedEdge[1, 2], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$4"],
RowBox[{"2", "\[DirectedEdge]", "3"}]],
Annotation[#, 
DirectedEdge[2, 3], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$5"],
RowBox[{"3", "\[UndirectedEdge]", "5"}]],
Annotation[#, 
UndirectedEdge[3, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$6"],
RowBox[{"3", "\[DirectedEdge]", "4"}]],
Annotation[#, 
DirectedEdge[3, 4], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$7"],
RowBox[{"4", "\[DirectedEdge]", "5"}]],
Annotation[#, 
DirectedEdge[4, 5], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[LineBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$8"],
RowBox[{"5", "\[UndirectedEdge]", "7"}]],
Annotation[#, 
UndirectedEdge[5, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$9"],
RowBox[{"5", "\[DirectedEdge]", "6"}]],
Annotation[#, 
DirectedEdge[5, 6], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$10"],
RowBox[{"6", "\[DirectedEdge]", "7"}]],
Annotation[#, 
DirectedEdge[6, 7], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$11"],
RowBox[{"7", "\[DirectedEdge]", "8"}]],
Annotation[#, 
DirectedEdge[7, 8], "Tooltip"]& ], 
TagBox[
TooltipBox[
TagBox[ArrowBox[{DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}],
"DynamicName",
BoxID -> "EdgeLabelID$12"],
RowBox[{"8", "\[DirectedEdge]", "1"}]],
Annotation[#, 
DirectedEdge[8, 1], "Tooltip"]& ]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], 
TagBox[{
TagBox[DiskBox[{-0.707106781186548, 0.7071067811865482}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$1"], InsetBox["1", Offset[{2, 2}, DynamicLocation[
             "VertexID$1", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$1"], 
TagBox[{
TagBox[DiskBox[{-1., 1.0106430996148606`*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$2"], InsetBox["2", Offset[{2, 2}, DynamicLocation[
             "VertexID$2", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$2"], 
TagBox[{
TagBox[DiskBox[{-0.707106781186547, -0.7071067811865468}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$3"], InsetBox["3", Offset[{2, 2}, DynamicLocation[
             "VertexID$3", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$3"], 
TagBox[{
TagBox[DiskBox[{6.049014748177263*^-16, -1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$4"], InsetBox["4", Offset[{2, 2}, DynamicLocation[
             "VertexID$4", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$4"], 
TagBox[{
TagBox[DiskBox[{0.7071067811865481, -0.7071067811865483}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$5"], InsetBox["5", Offset[{2, 2}, DynamicLocation[
             "VertexID$5", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$5"], 
TagBox[{
TagBox[DiskBox[{1., -1.133107779529596*^-15}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$6"], InsetBox["6", Offset[{2, 2}, DynamicLocation[
             "VertexID$6", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$6"], 
TagBox[{
TagBox[DiskBox[{0.707106781186547, 0.7071067811865467}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$7"], InsetBox["7", Offset[{2, 2}, DynamicLocation[
             "VertexID$7", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$7"], 
TagBox[{
TagBox[DiskBox[{-7.044813998280222*^-16, 1.}, 0.02261146496815286],
"DynamicName",
BoxID -> "VertexID$8"], InsetBox["8", Offset[{2, 2}, DynamicLocation[
             "VertexID$8", Automatic, {Right, Top}]], ImageScaled[{0, 0}],
BaseStyle->"Graphics"]},
"DynamicName",
BoxID -> "VertexLabelID$8"]}}],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->"NetworkGraphics",
FormatType->TraditionalForm,
FrameTicks->None,
ImageSize->{145.03125, Automatic}]\)

Use any kind of vertex to form the cycle:

In[9]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/cedd058c-abff-4ed2-8f9d-1acdf5a3728d"]
Out[9]=

Options (12) 

AnnotationRules (2) 

Specify an annotation for vertices:

In[10]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, AnnotationRules -> {1 -> {VertexLabels -> "hello"}}, PlotTheme -> "Detailed"]
Out[10]=

Edges:

In[11]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, AnnotationRules -> {1 \[UndirectedEdge] 2 -> {EdgeLabels -> "hello"}}, PlotTheme -> "Detailed", ImageSize -> Tiny]
Out[11]=

GraphHighlight (3) 

Highlight vertices:

In[12]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, GraphHighlight -> {3, 7, 8, 9, 10, 11}, PlotTheme -> "Detailed"]
Out[12]=

Highlight edges:

In[13]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, GraphHighlight -> {3 \[UndirectedEdge] 7, 7 \[UndirectedEdge] 8, 8 \[UndirectedEdge] 9, 9 \[UndirectedEdge] 10, 10 \[UndirectedEdge] 11, 11 \[UndirectedEdge] 3}, PlotTheme -> "Detailed"]
Out[13]=

Highlight vertices and edges:

In[14]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, GraphHighlight -> {3, 3 \[UndirectedEdge] 7, 7, 7 \[UndirectedEdge] 8, 8, 8 \[UndirectedEdge] 9, 9, 9 \[UndirectedEdge] 10, 10, 10 \[UndirectedEdge] 11, 11, 11 \[UndirectedEdge] 3}, PlotTheme -> "Detailed"]
Out[14]=

PlotTheme (2) 

Use a common base theme:

In[15]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, PlotTheme -> "Business"]
Out[15]=

Use a monochrome theme:

In[16]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, PlotTheme -> "Monochrome"]
Out[16]=

VertexSize (3) 

By default, the size of vertices is computed automatically:

In[17]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, VertexSize -> Automatic]
Out[17]=

Specify the size of all vertices using symbolic vertex size:

In[18]:=
Table[ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
          Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
             3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
             5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
         GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
          1.0388715748066573`, 0.5716078363709886}, {
          0.454770110930767, 0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
             3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]
Out[18]=

Specify the size for individual vertices:

In[19]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, VertexSize -> {1 -> 0.2, 2 -> 0.3}]
Out[19]=

VertexStyle (2) 

Style all vertices:

In[20]:=
Table[ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
          Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
             3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
             5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
         GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
          1.0388715748066573`, 0.5716078363709886}, {
          0.454770110930767, 0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
             3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, VertexStyle -> style, VertexSize -> 0.3, PlotLabel -> ToString[style]], {style, {Yellow, EdgeForm[Dashed]}}]
Out[20]=

Style individual vertices:

In[21]:=
ResourceFunction["CycleAdd"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6}, {Null, 
SparseArray[
         Automatic, {6, 6}, 0, {1, {{0, 3, 7, 12, 17, 21, 24}, {{2}, {3}, {4}, {1}, {
            3}, {4}, {5}, {1}, {2}, {4}, {5}, {6}, {1}, {2}, {3}, {
            5}, {6}, {2}, {3}, {4}, {6}, {3}, {4}, {5}}}, Pattern}]}]]}, 
TagBox[GraphicsGroupBox[
        GraphicsComplexBox[{{2.077635572424192, 0.14538312809263582`}, {1.622121700519018, 0.9989210826630444}, {1.0379005300359831`, 0.}, {
         1.0388715748066573`, 0.5716078363709886}, {0.454770110930767,
          0.9978125230323187}, {0., 0.14605821591057733`}}, {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], LineBox[{{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {2, 5}, {
            3, 4}, {3, 5}, {3, 6}, {4, 5}, {4, 6}, {5, 6}}]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.023238294114515057], DiskBox[2, 0.023238294114515057], DiskBox[3, 0.023238294114515057], DiskBox[4, 0.023238294114515057], DiskBox[5, 0.023238294114515057], DiskBox[6, 0.023238294114515057]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\), {3, 7, 8, 9, 10, 11}, VertexStyle -> {1 -> Blue, 2 -> Red}, VertexSize -> 0.2, PlotTheme -> "Detailed"]
Out[21]=

Applications (3) 

Generate the cycle graph of given list of vertex:

In[22]:=
ResourceFunction["CycleAdd"][Graph[{}], Alphabet[], PlotTheme -> "Detailed"]
Out[22]=

Find the circle graph of consecutive letters in a phrase:

In[23]:=
ResourceFunction["CycleAdd"][Graph[{}], Characters[
  "It combines new ideas with the latest research in physics, mathematics and computation in the push to achieve this ultimate goal of science"], GraphLayout -> "CircularEmbedding", PlotTheme -> "Detailed"]
Out[23]=

Find the circle graph of consecutive words in a phrase:

In[24]:=
ResourceFunction["CycleAdd"][Graph[{}], StringSplit[
  "It combines new ideas with the latest research in physics, mathematics and computation in the push to achieve this ultimate goal of science"], GraphLayout -> "CircularEmbedding", PlotTheme -> "Detailed"]
Out[24]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 04 November 2024

Related Resources

License Information