Macaulay2 » Documentation
Packages » Graphs :: addEdge
next | previous | forward | backward | up | index | toc

# addEdge -- A method for adding edges to a graph

- Usage:
    `H = addEdges' (G, L)`
    `H = addEdge (G, S)`
- Inputs:
  - G, a graph,
  - L, a list, This List should be composed of other Lists, just as one would input an edge set
  - S, a set, This is used when only one edge needs to be used via addEdge
- Outputs:
  - H, a graph, The Graph with the new edge

## Description

This method will take in a Graph and a List of new edges, and output a graph with these new edges along with the previous edges.

    i1 : H = cycleGraph 4;

    i2 : G = addEdge(H, set {0,2})

    o2 = Graph{0 => {1, 2, 3}}
               1 => {0, 2}
               2 => {0, 1, 3}
               3 => {0, 2}

    o2 : Graph

    i3 : G = addEdges'(H, {{0,2},{3,1}})

    o3 = Graph{0 => {1, 2, 3}}
               1 => {0, 2, 3}
               2 => {0, 1, 3}
               3 => {0, 1, 2}

    o3 : Graph

## See also

- addVertices -- A method for adding a set of vertices to a graph

## Ways to use addEdge:

- `addEdge(Digraph,Set)`

## For the programmer

The object addEdge is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Graphs.m2:4959:0.