func (g *GreedyGraphMem) RemoveEdge(a, b string) bool {
	var inParent, inChild bool
	parents, ok := g.parents[a]
	if ok {
		inParent = parents.Contains(b)
		parents.Remove(b)
	}
	children, ok := g.children[b]
	if ok {
		inChild = children.Contains(a)
		children.Remove(a)
	}
	return inParent && inChild
}
RemoveEdge removes an edge from node a to b.
b is not parent of a
a is not child of b
Returns true if the edge was removed.
package phantom
import (
	"fmt"
	"sort"
	"strings"
)
type kChain struct {
	chain *OrderedStringSet
	minHeight int
}
type GreedyGraphMem struct {
	k int
	children map[string]*OrderedStringSet
	parents map[string]*OrderedStringSet
	height map[string]int
	coloringTip string
	coloringChain *OrderedStringSet
	mainKChain *kChain
	bluePastOrder *ChainMap
	redPastOrder *ChainMap
	blueAntiPastOrder *OrderMap
	redAntiPastOrder *OrderMap
	uncoloredUnorderedAntiPast *OrderMap
	pastOrder *ChainMap
	antiPastOrder *ChainMap
	antiPast *ChainMap
	coloringOrder *ChainMap
	order *ChainMap
	blueCount map[string]int
	coloringParents map[string]string
	blueDiffPastOrder map[string]OrderMap
	redDiffPastOrder map[string]OrderMap
	selfOrder map[string]int
}
func (g *GreedyGraphMem) Add(id string, parents []string) (bool, error) {
	ok, err := g.AddNode(id)
	if err != nil {
		return ok, err
	}
	if len(parents) > 0 {
		ok, err := g.AddMultiEdge(id, parents)
		if err != nil {
			return ok, err
		}
	}
	_, err = g.Height(id)
	if err != nil {
		return ok, err
	}
	g.updateColoringIncrementally(id, parents)
	g.updateTopologicalOrderIncrementally(id)
	return ok, nil
}
func (g *GreedyGraphMem) AddNode(id string) (bool, error) {
	_, ok := g.parents[id]
	if ok {
		return false, nil
	}
	g.parents[id] = NewOrderedStringSet()
	g.children[id] = NewOrderedStringSet()
	return true, nil
}
func (g *GreedyGraphMem) AddEdge(a, b string) (bool, error) {
	_, err := g.AddNode(a)
	if err != nil {
		return false, err
	}
	_, err = g.AddNode(b)
	if err != nil {
		return false, err
	}
	parentsOfA, ok := g.parents[a]
	if !ok {
		return false, fmt.Errorf("failed to add edge from %s to %s; no node entry for %s", a, b, a)
	}
	childrenOfB, ok := g.children[b]
	if !ok {
		return false, fmt.Errorf("failed to add edge from %s to %s; no node entry for %s", a, b, b)
	}
	if parentsOfA.Contains(b) {
		return false, nil
	}
	parentsOfA.Add(b)
	childrenOfB.Add(a)
	return true, nil
}
func (g *GreedyGraphMem) AddMultiEdge(a string, parents []string) (bool, error) {
	added := 0
	for _, p := range parents {
		ok, err := g.AddEdge(a, p)
		if err != nil {
			return false, err
		}
		if ok {
			added += 1
		}
	}
	return added == len(parents), nil
}