Beispiel #1
0
func (sg *SubGraph) AsIndices() *digraph.Indices {
	b := digraph.Build(len(sg.V), len(sg.E))
	for vidx := range sg.V {
		u := &sg.V[vidx]
		b.AddVertex(u.Color)
	}
	for eidx := range sg.E {
		src := &b.V[sg.E[eidx].Src]
		targ := &b.V[sg.E[eidx].Targ]
		color := sg.E[eidx].Color
		b.AddEdge(src, targ, color)
	}
	return digraph.NewIndices(b, 1)
}
Beispiel #2
0
func (dt *Digraph) Init(b *digraph.Builder, l *digraph.Labels) (err error) {
	dt.lock.Lock()
	// i := digraph.NewIndices(b, dt.config.Support, dt.Mode & ExtFromFreqEdges == ExtFromFreqEdges)
	i := digraph.NewIndices(b, dt.config.Support)
	errors.Logf("DEBUG", "done building indices")
	dt.G = i.G
	dt.Indices = i
	dt.Labels = l
	dt.lock.Unlock()

	errors.Logf("DEBUG", "computing starting points")
	for color, _ := range dt.Indices.ColorIndex {
		sg := subgraph.Build(1, 0).FromVertex(color).Build()
		_, exts, embs, _, _, err := ExtsAndEmbs(dt, sg, nil, nil, nil, dt.Mode, false)
		if err != nil {
			return err
		}
		n := NewEmbListNode(dt, sg, exts, embs, nil, nil)
		dt.lock.Lock()
		dt.FrequentVertices = append(dt.FrequentVertices, n)
		dt.lock.Unlock()
	}
	return nil
}