Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LineNetworkConfig = newNetworkConfigFn(func(adjacentNodes AdjacentNodes) { n := len(adjacentNodes) for i := 0; i+1 < n; i++ { adjacentNodes.Connect(i, i+1) } })
View Source
var SmallWorldNetworkConfig = newNetworkConfigFn(func(adjacentNodes AdjacentNodes) { const ( rateOfNeighborConnections = 0.2 rateOfRandomConnections = 0.2 ) n := len(adjacentNodes) for i := range n { adjacentNodes.ConnectRandomDirection(i, (i+1)%n) for distance := 2; distance < 4; distance++ { if rand.Float64() < rateOfNeighborConnections { adjacentNodes.ConnectRandomDirection(i, (i+distance)%n) } } if rand.Float64() < rateOfRandomConnections { adjacentNodes.ConnectRandomDirection(i, rand.Intn(n)) } } })
Functions ¶
This section is empty.
Types ¶
type AdjacentNodes ¶
type AdjacentNodes []map[int]struct{}
AdjacentNodes is a slice of N sets, each representing the nodes adjacent to the node at the index.
func NewAdjacentNodes ¶
func NewAdjacentNodes(n int) AdjacentNodes
NewAdjacentNodes creates a new AdjacentNodes with N nodes with initially no connections.
func (AdjacentNodes) Connect ¶
func (a AdjacentNodes) Connect(from, to int)
func (AdjacentNodes) ConnectRandomDirection ¶
func (a AdjacentNodes) ConnectRandomDirection(from, to int) bool
func (AdjacentNodes) Validate ¶ added in v0.15.20
func (a AdjacentNodes) Validate() bool
type NetworkConfigFn ¶
type NetworkConfigFn func(int) AdjacentNodes
NetworkConfigFn is a function that returns an AdjacentNodes for a given number of nodes.
Click to show internal directories.
Click to hide internal directories.