func (g *Graph) RemoveEdge(first, second *Vertex) {
	if first.Graph == second.Graph && first.IsAdjacent(second) {
		first.RemoveEdge(second)
	}
}
RemoveEdge removes an edge between two vertices if it exists
package graph
type Vertex struct {
	Value int
	Graph *Graph
	Neighbors []*Vertex
}
func (v *Vertex) GetNeighbors() []*Vertex {
	return v.Neighbors
}
func (v *Vertex) IsAdjacent(other *Vertex) bool {
	if v.Graph != other.Graph {
		return false
	}
	for _, n := range v.Neighbors {
		if n == other {
			return true
		}
	}
	return false
}
func (v *Vertex) RemoveEdge(other *Vertex) bool {
	if v.Graph != other.Graph {
		return false
	}
	if !v.IsAdjacent(other) {
		return false
	}
	updateNeighbors := func(cur, target *Vertex) []*Vertex {
		var removeIndex int
		for i, n := range cur.Neighbors {
			if n == target {
				removeIndex = i
			}
		}
		if len(cur.Neighbors) == 1 {
			return []*Vertex{}
		}
		return append(cur.Neighbors[:removeIndex], cur.Neighbors[removeIndex+1:]...)
	}
	v.Neighbors = updateNeighbors(v, other)
	other.Neighbors = updateNeighbors(other, v)
	return true
}
type Graph struct {
	Vertices []*Vertex
}
func NewGraph() *Graph {
	return &Graph{}
}
func (g *Graph) Adjacent(first, second *Vertex) bool {
	if first.Graph != g || second.Graph != g {
		return false
	}
	return first.IsAdjacent(second)
}
func (g *Graph) Edges() [][]int {
	var edges [][]int
	for _, v := range g.Vertices {
		for _, n := range v.Neighbors {
			edges = append(edges, []int{v.Value, n.Value})
		}
	}
	return edges
}
func (g *Graph) AddVertex(value int) *Vertex {
	v := &Vertex{Value: value, Graph: g}
	g.Vertices = append(g.Vertices, v)
	return v
}
func (g *Graph) RemoveVertex(v *Vertex) bool {
	var removeIndex int
	if v.Graph != g {
		return false
	}
	for i, vertex := range g.Vertices {
		if vertex == v {
			removeIndex = i
			for _, neighbor := range vertex.Neighbors {
				neighbor.RemoveEdge(v)
			}
		}
	}
	g.Vertices = append(g.Vertices[:removeIndex], g.Vertices[removeIndex+1:]...)
	return true
}
func (g *Graph) AddEdge(first, second *Vertex) {
	if first.Graph == second.Graph && !first.IsAdjacent(second) {
		second.Neighbors = append(second.Neighbors, first)
		first.Neighbors = append(first.Neighbors, second)
	}
}