func (sg *SubGraph) Walks(labels map[int]int) (W matrix.Matrix) { var err error L, E := sg.LE(labels) LT := matrix.Transpose(L) var En matrix.Matrix = matrix.Eye(E.Rows()) var SEn matrix.Matrix = matrix.Zeros(E.Rows(), E.Cols()) for i := 0; i < len(sg.V); i++ { En, err = En.Times(E) if err != nil { log.Fatal(err) } r, c := SEn.GetSize() for x := 0; x < r; x++ { for y := 0; y < c; y++ { if En.Get(x, y) != 0 { SEn.Set(x, y, 1) } } } // err = SEn.Add(En) // if err != nil { // log.Fatal(err) // } } LE, err := L.Times(SEn) if err != nil { log.Fatal(err) } LELT, err := LE.Times(LT) if err != nil { log.Fatal(err) } return LELT }
func (m *Sparse) Dense() *matrix.DenseMatrix { d := matrix.Zeros(m.Rows, m.Cols) for _, e := range m.Entries { d.Set(e.Row, e.Col, e.Value) } return d }
func (sg *SubGraph) LE(labels map[int]int) (L, E matrix.Matrix) { V := len(sg.V) VE := V + len(sg.E) L = matrix.Zeros(len(labels), VE) E = matrix.Zeros(VE, VE) for i := range sg.V { L.Set(labels[sg.V[i].Color], i, 1) } for i := range sg.E { L.Set(labels[sg.E[i].Color], V+i, 1) } for i := range sg.E { E.Set(sg.E[i].Src, V+i, 1) E.Set(V+i, sg.E[i].Targ, 1) } return L, E }