func SubgraphRemove(g Graph, nodes []int, edges []Edge) Subgraph {
	rmNodes := make(map[int]struct{}, len(nodes))
	for _, node := range nodes {
		rmNodes[node] = struct{}{}
	}
	rmEdges := make(map[Edge]struct{}, len(edges))
	for _, edge := range edges {
		rmEdges[edge] = struct{}{}
	}
	newNodes := make([]listSubgraphNode, 0, g.NumNodes()-len(rmNodes))
	oldToNew := make(map[int]int, cap(newNodes))
	for oldNode := 0; oldNode < g.NumNodes(); oldNode++ {
		if _, ok := rmNodes[oldNode]; ok {
			continue
		}
		newNode := len(newNodes)
		newNodes = append(newNodes, listSubgraphNode{oldNode: oldNode})
		oldToNew[oldNode] = newNode
	}
	for i := range newNodes {
		newNode := &newNodes[i]
		oldNode := newNode.oldNode
		oldOut := g.Out(oldNode)
		for j, oldNode2 := range oldOut {
			if _, ok := rmNodes[oldNode2]; ok {
				continue
			}
			if _, ok := rmEdges[Edge{oldNode, j}]; ok {
				continue
			}
			newNode.out = append(newNode.out, oldToNew[oldNode2])
			newNode.oldEdges = append(newNode.oldEdges, j)
		}
	}
	return &listSubgraph{g, newNodes}
}
SubgraphRemove returns a subgraph of g that removes the given nodes
and edges from g, as well as all edges incident to those nodes.
package graph
type Subgraph interface {
	Graph
	Underlying() Graph
	NodeMap(underlyingMap func(node int) interface{}) func(node int) interface{}
	EdgeMap(underlyingMap func(node, edge int) interface{}) func(node, edge int) interface{}
}
func SubgraphKeep(g Graph, nodes []int, edges []Edge) Subgraph {
	gNodes := g.NumNodes()
	oldToNew := make(map[int]int, len(nodes))
	for newNode, oldNode := range nodes {
		if oldNode < 0 || oldNode >= gNodes {
			panic("node not in underlying graph")
		}
		if _, ok := oldToNew[oldNode]; ok {
			panic("duplicate node")
		}
		oldToNew[oldNode] = newNode
	}
	newNodes := make([]listSubgraphNode, len(nodes))
	for i, oldNode := range nodes {
		newNodes[i].oldNode = oldNode
	}
	for _, oldEdge := range edges {
		newNode := &newNodes[oldToNew[oldEdge.Node]]
		oldTo := g.Out(oldEdge.Node)[oldEdge.Edge]
		newTo := oldToNew[oldTo]
		newNode.out = append(newNode.out, newTo)
		newNode.oldEdges = append(newNode.oldEdges, oldEdge.Edge)
	}
	return &listSubgraph{g, newNodes}
}