Beispiel #1
0
func CheckCount(tree store.SubGraphs, limit int, action CollectAction) CollectAction {
	return func(lg *labelGraph) {
		if tree.Count(lg.label) <= limit {
			action(lg)
		}
	}
}
Beispiel #2
0
func (c *ParHashCollector) makePartitions(sgs store.SubGraphs) (p_it partitionIterator) {
	keys := sgs.Keys()
	p_it = func() (part store.Iterator, next partitionIterator) {
		var key []byte
		key, keys = keys()
		if keys == nil {
			return nil, nil
		}
		return bufferedIterator(sgs.Find(key), 10), p_it
	}
	return p_it
}
Beispiel #3
0
func writeAllPatterns(all store.SubGraphs, nodeAttrs *bptree.BpTree, outputDir string) {
	alle, err := os.Create(path.Join(outputDir, "all-embeddings.dot"))
	if err != nil {
		log.Fatal(err)
	}
	defer alle.Close()
	allp, err := os.Create(path.Join(outputDir, "all-patterns.dot"))
	if err != nil {
		log.Fatal(err)
	}
	defer allp.Close()
	count := 0
	for key, next := all.Keys()(); next != nil; key, next = next() {
		writePattern(count, outputDir, alle, allp, nodeAttrs, all, key)
		count++
	}
}
Beispiel #4
0
func MaximalSubGraphs(all store.SubGraphs, nodeAttrs *bptree.BpTree, tempDir string) (<-chan []byte, error) {
	labelsBf, err := fmap.CreateBlockFile(path.Join(tempDir, "labels.bptree"))
	if err != nil {
		return nil, err
	}
	labels, err := bptree.New(labelsBf, -1, 1)
	if err != nil {
		return nil, err
	}
	keys := make(chan []byte)
	go func() {
		defer labelsBf.Close()
		var cur []byte
		var had bool = false
		for key, sg, next := all.Backward()(); next != nil; key, sg, next = next() {
			if cur != nil && !bytes.Equal(key, cur) {
				if !had {
					keys <- cur
				}
				had = false
			}
			has, err := labels.Has(key)
			if err != nil {
				log.Fatal(err)
			}
			if has {
				had = true
			}
			if !bytes.Equal(cur, key) {
				// add all of the (potential) parents of this node
				for eIdx := range sg.E {
					nsg, _ := sg.RemoveEdge(eIdx)
					addToLabels(labels, nsg.ShortLabel())
				}
			}
			cur = key
		}
		if !had && cur != nil {
			keys <- cur
		}
		close(keys)
	}()
	return keys, nil
}
Beispiel #5
0
func TreeAdd(tree store.SubGraphs) CollectAction {
	return func(lg *labelGraph) {
		tree.Add(lg.label, lg.sg)
	}
}