Ejemplo n.º 1
0
// NewRandomGraph creates a new random graph generator.
func NewRandomGraph(n int) (generator.Generator, error) {
	if n < 1 {
		return nil, fmt.Errorf("invalid number of nodes %d<1", n)
	}
	nt, err := node.NewType("/gn")
	if err != nil {
		return nil, err
	}
	p, err := predicate.NewImmutable("follow")
	if err != nil {
		return nil, err
	}
	return &randomGraph{
		nodes:     n,
		nodeType:  nt,
		predicate: p,
	}, nil
}
Ejemplo n.º 2
0
// New creates a new tree generator. The triples are generated using breadth
// search first. All predicates are immutable and use the predicate
// `"parent_of"@[]`.`
func New(branch int) (generator.Generator, error) {
	if branch < 1 {
		return nil, fmt.Errorf("invalid branch factor %d", branch)
	}
	nt, err := node.NewType("/tn")
	if err != nil {
		return nil, err
	}
	p, err := predicate.NewImmutable("parent_of")
	if err != nil {
		return nil, err
	}
	return &treeGenerator{
		branch:    branch,
		nodeType:  nt,
		predicate: p,
	}, nil
}