func (g *ReducedDirected) Expanded() ReducedGraph {
	return g.parent
}
Expanded returns the next lower level of the module clustering or nil
if at the lowest level.
package community
import (
	"math"
	"math/rand"
	"sort"
	"gonum.org/v1/gonum/graph"
	"gonum.org/v1/gonum/graph/internal/ordered"
	"gonum.org/v1/gonum/graph/internal/set"
)
func qDirected(g graph.Directed, communities [][]graph.Node, resolution float64) float64 {
	nodes := g.Nodes()
	weight := positiveWeightFuncFor(g)
	var m float64
	k := make(map[int64]directedWeights, len(nodes))
	for _, n := range nodes {
		var wOut float64
		u := n
		for _, v := range g.From(u) {
			wOut += weight(u, v)
		}
		var wIn float64
		v := n
		for _, u := range g.To(v) {
			wIn += weight(u, v)
		}
		w := weight(n, n)
		m += w + wOut  
		k[n.ID()] = directedWeights{out: w + wOut, in: w + wIn}
	}
	if communities == nil {
		var q float64
		for _, u := range nodes {
			kU := k[u.ID()]
			q += weight(u, u) - resolution*kU.out*kU.in/m
		}
		return q / m
	}
	var q float64
	for _, c := range communities {
		for _, u := range c {
			kU := k[u.ID()]
			for _, v := range c {
				kV := k[v.ID()]
				q += weight(u, v) - resolution*kU.out*kV.in/m
			}
		}
	}
	return q / m
}
func louvainDirected(g graph.Directed, resolution float64, src *rand.Rand) ReducedGraph {
	c := reduceDirected(g, nil)
	rnd := rand.Intn
	if src != nil {
		rnd = src.Intn
	}
	for {
		l := newDirectedLocalMover(c, c.communities, resolution)
		if l == nil {
			return c
		}
		if done := l.localMovingHeuristic(rnd); done {
			return c
		}
		c = reduceDirected(c, l.communities)
	}
}
type ReducedDirected struct {
	nodes []community
	directedEdges
	communities [][]graph.Node
	parent *ReducedDirected
}
var (
	reducedDirected = (*ReducedDirected)(nil)
	_ graph.WeightedDirected = reducedDirected
	_ ReducedGraph           = reducedDirected
)
func (g *ReducedDirected) Communities() [][]graph.Node {
	communities := make([][]graph.Node, len(g.communities))
	if g.parent == nil {
		for i, members := range g.communities {
			comm := make([]graph.Node, len(members))
			for j, n := range members {
				nodes := g.nodes[n.ID()].nodes
				if len(nodes) != 1 {
					panic("community: unexpected number of nodes in base graph community")
				}
				comm[j] = nodes[0]
			}
			communities[i] = comm
		}
		return communities
	}
	sub := g.parent.Communities()
	for i, members := range g.communities {
		var comm []graph.Node
		for _, n := range members {
			comm = append(comm, sub[n.ID()]...)
		}
		communities[i] = comm
	}
	return communities
}
func (g *ReducedDirected) Structure() [][]graph.Node {
	return g.communities
}