func (n *Network) Graph(ctx context.Context, req *pb.GraphRequest, resp *pb.GraphResponse) error {
	depth := uint(req.Depth)
	if depth <= 0 || depth > mucp.MaxDepth {
		depth = mucp.MaxDepth
	}
	peers := util.PeersToProto(n.Network, depth)
	resp.Root = peers
	return nil
}
Graph returns the network graph from this root node
package handler
import (
	"context"
	pb "github.com/micro/micro/v3/proto/network"
	pbRtr "github.com/micro/micro/v3/proto/router"
	"github.com/micro/micro/v3/service/errors"
	log "github.com/micro/micro/v3/service/logger"
	"github.com/micro/micro/v3/service/network"
	"github.com/micro/micro/v3/service/network/mucp"
	"github.com/micro/micro/v3/service/network/util"
	"github.com/micro/micro/v3/service/router"
	authns "github.com/micro/micro/v3/util/auth/namespace"
	"github.com/micro/micro/v3/util/namespace"
)
type Network struct {
	Network network.Network
}
func flatten(n network.Node, visited map[string]bool) []network.Node {
	if n == nil {
		return nil
	}
	if visited == nil {
		visited = make(map[string]bool)
	}
	var nodes []network.Node
	if !visited[n.Id()] {
		nodes = append(nodes, n)
	}
	visited[n.Id()] = true
	for _, node := range n.Peers() {
		nodes = append(nodes, flatten(node, visited)...)
	}
	return nodes
}
func (n *Network) Connect(ctx context.Context, req *pb.ConnectRequest, resp *pb.ConnectResponse) error {
	if len(req.Nodes) == 0 {
		return nil
	}
	nodes := n.Network.Options().Nodes
	nodeMap := make(map[string]bool)
	for _, node := range nodes {
		nodeMap[node] = true
	}
	for _, node := range req.Nodes {
		if len(node.Address) == 0 {
			continue
		}
		if _, ok := nodeMap[node.Address]; ok {
			continue
		}
		nodeMap[node.Address] = true
		nodes = append(nodes, node.Address)
	}
	log.Infof("Network.Connect setting peers: %v", nodes)
	n.Network.Init(
		network.Nodes(nodes...),
	)
	n.Network.Connect()
	return nil
}
func (n *Network) Nodes(ctx context.Context, req *pb.NodesRequest, resp *pb.NodesResponse) error {
	nodes := map[string]network.Node{}
	peers := flatten(n.Network, nil)
	for _, peer := range peers {
		if peer == nil {
			continue
		}
		if _, ok := nodes[peer.Id()]; ok {
			continue
		}
		nodes[n.Network.Id()] = peer
		resp.Nodes = append(resp.Nodes, &pb.Node{
			Id:      peer.Id(),
			Address: peer.Address(),
		})
	}
	return nil
}