本文整理汇总了Golang中github.com/timtadh/goiso.SubGraph.Lattice方法的典型用法代码示例。如果您正苦于以下问题:Golang SubGraph.Lattice方法的具体用法?Golang SubGraph.Lattice怎么用?Golang SubGraph.Lattice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/timtadh/goiso.SubGraph
的用法示例。
在下文中一共展示了SubGraph.Lattice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PrMatrices
func (m *RandomWalkMiner) PrMatrices(sg *goiso.SubGraph) (vp int, Q, R, u Sparse, err error) {
defer func() {
if e := recover(); e != nil {
stack := string(debug.Stack())
err = fmt.Errorf("%v\n%v", e, stack)
}
}()
lattice := sg.Lattice()
log.Printf("lattice size %d %v", len(lattice.V), sg.Label())
p := m.probabilities(lattice)
log.Println("got transistion probabilities", p)
vp = m.startingPoints.Size()
Q = Sparse{
Rows: len(lattice.V) - 1,
Cols: len(lattice.V) - 1,
Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
}
R = Sparse{
Rows: len(lattice.V) - 1,
Cols: 1,
Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
}
u = Sparse{
Rows: 1,
Cols: len(lattice.V) - 1,
Entries: make([]*SparseEntry, 0, len(lattice.V)-1),
}
for i, x := range lattice.V {
if len(x.V) == 1 && len(x.E) == 0 && i < len(lattice.V)-1 {
u.Entries = append(u.Entries, &SparseEntry{0, i, 1.0 / float64(vp), vp})
}
}
for _, e := range lattice.E {
if e.Targ >= len(lattice.V)-1 {
R.Entries = append(R.Entries, &SparseEntry{e.Src, 0, 1.0 / float64(p[e.Src]), p[e.Src]})
} else {
Q.Entries = append(Q.Entries, &SparseEntry{e.Src, e.Targ, 1.0 / float64(p[e.Src]), p[e.Src]})
}
}
return vp, Q, R, u, nil
}