// EdgesTo returns edges that reference req.RefTo.
// It filters out since-deleted permanode edges.
483514
func (h *Handler) EdgesTo(req *EdgesRequest) (*EdgesResponse, error) {
	ctx := context.TODO()
	h.index.RLock()
	defer h.index.RUnlock()

	toRef := req.ToRef
	toRefStr := toRef.String()
	var edgeItems []*EdgeItem

	edges, err := h.index.EdgesTo(toRef, nil)
	if err != nil {
		panic(err)
	}

	type edgeOrError struct {
		edge *EdgeItem // or nil
		err  error
	}
	resc := make(chan edgeOrError)
	verify := func(edge *camtypes.Edge) {
		db, err := h.NewDescribeRequest().DescribeSync(ctx, edge.From)
		if err != nil {
			resc <- edgeOrError{err: err}
			return
		}
		found := false
		if db.Permanode != nil {
			for attr, vv := range db.Permanode.Attr {
				if index.IsBlobReferenceAttribute(attr) {
					for _, v := range vv {
						if v == toRefStr {
							found = true
						}
					}
				}
			}
		}
		var ei *EdgeItem
		if found {
			ei = &EdgeItem{
				From:     edge.From,
				FromType: "permanode",
			}
		}
		resc <- edgeOrError{edge: ei}
	}
	verifying := 0
	for _, edge := range edges {
		if edge.FromType == "permanode" {
			verifying++
			go verify(edge)
			continue
		}
		ei := &EdgeItem{
			From:     edge.From,
			FromType: edge.FromType,
		}
		edgeItems = append(edgeItems, ei)
	}
	for i := 0; i < verifying; i++ {
		res := <-resc
		if res.err != nil {
			return nil, res.err
		}
		if res.edge != nil {
			edgeItems = append(edgeItems, res.edge)
		}
	}

	return &EdgesResponse{
		ToRef:   toRef,
		EdgesTo: edgeItems,
	}, nil
}
1330690
func (g *Graph) Edges() []Edge {
	list := g.edges.List()
	result := make([]Edge, len(list))
	for i, v := range list {
		result[i] = v.(Edge)
	}

	return result
}
656729
func edgeKind(g genericgraph.Graph, from, to gonum.Node, desiredKind string) bool {
	edge := g.Edge(from, to)
	kinds := g.EdgeKinds(edge)
	return kinds.Has(desiredKind)
}
890329
func (r *Rename) GetTo() string {
	if r == nil || r.To == nil {
		return ""
	}
	return *r.To
}
1088928
func FilterTo(dst, src string, trunc bool, filter io2.LineFilterFunc) error {
	return Read(src, func(sfd *os.File) (err error) {
		return OpenOrCreate(dst, trunc, func(dfd *os.File) error {
			return io2.Filter(sfd, dfd, true, filter)
		})
	})
}
1235080
func (r Raw) MarshalTo(data []byte) (n int, err error) {
	if len(r) == 0 {
		return 0, nil
	}
	copy(data, r)
	return len(r), nil
}
788778
func (bm *BlockMeta) MarshalTo(data []byte) (int, error) {
	bs, err := bm.Marshal()
	if err != nil {
		return -1, err
	}
	return copy(data, bs), nil
}
760890
func (ds *DestSme) SerializeTo(w io.Writer) error {
	_, err := w.Write(ds.Bytes())
	return err
}
369829
func (gc *StackGraphicContext) ArcTo(cx, cy, rx, ry, startAngle, delta float64) {
	gc.current.Path.ArcTo(cx, cy, rx, ry, startAngle, delta)
}
979544
func MarshalTo(w io.Writer, v interface{}) error {
	rv := reflect.ValueOf(v)
	if rv.Kind() == reflect.Ptr {
		rv = rv.Elem()
	}

	var err error
	switch rv.Kind() {
	case reflect.Map:
		if m, ok := v.(map[string]string); ok {
			err = marshalMapTo(w, m)
			break
		}
		err = fmt.Errorf("not a map[string]string")
	case reflect.Struct:
		err = marshalStructTo(w, rv)
	default:
		err = fmt.Errorf("not a struct/map: %v", v)
	}
	return err
}
62171
func (n *Node) BelongsTo(g *Graph) bool {
	return n.Key.set == &g.KeySet
}
388370
func (b *Block) MarshalTo(data []byte) (int, error) {
	bs, err := b.Marshal()
	if err != nil {
		return -1, err
	}
	return copy(data, bs), nil
}
850263
func (l Traits) MarshalTo(data []byte) (int, error) {
	return l.protoType().MarshalTo(data)
}
375089
func (s Strings) MarshalTo(data []byte) (int, error) {
	return s.protoType().MarshalTo(data)
}
497476
func (p *Polygon) Edge(e int) Edge {
	var i int

	if len(p.cumulativeEdges) > 0 {
		for i = range p.cumulativeEdges {
			if i+1 >= len(p.cumulativeEdges) || e < p.cumulativeEdges[i+1] {
				e -= p.cumulativeEdges[i]
				break
			}
		}
	} else {
		// When the number of loops is small, use linear search. Most often
		// there is exactly one loop and the code below executes zero times.
		for i = 0; e >= len(p.Loop(i).vertices); i++ {
			e -= len(p.Loop(i).vertices)
		}
	}

	return Edge{p.Loop(i).OrientedVertex(e), p.Loop(i).OrientedVertex(e + 1)}
}
1198615
func RemoveInboundEdges(nodes []graph.Node) EdgeFunc {
	return func(g Interface, from, to graph.Node, edgeKinds sets.String) bool {
		for _, node := range nodes {
			if node == to {
				return false
			}
		}
		return true
	}
}
475809
func (g *UndirectedGraph) EdgeBetween(x, y graph.Node) graph.Edge {
	// We don't need to check if neigh exists because
	// it's implicit in the edges access.
	if !g.Has(x) {
		return nil
	}

	edge, _ := g.edges[x.ID()].Get(y.ID())
	return edge
}