Example #1
0
func (v *DotLoader) loadDigraph(input lattice.Input, labels *digraph.Labels) (graph *digraph.Builder, err error) {
	r, closer := input()
	text, err := ioutil.ReadAll(r)
	closer()
	if err != nil {
		return nil, err
	}
	G := digraph.Build(100, 1000)
	dp := &dotParse{
		b:      newBaseLoader(v.dt, G),
		d:      v,
		labels: labels,
		vids:   make(map[string]int32),
	}
	// s, err := dot.Lexer.Scanner(text)
	// if err != nil {
	// 	return nil, err
	// }
	// for _, _, eof := s.Next(); !eof; _, _, eof = s.Next() {}
	err = dot.StreamParse(text, dp)
	if err != nil {
		return nil, err
	}
	return G, nil
}
Example #2
0
File: main.go Project: timtadh/sfp
func convert(input io.Reader, output io.Writer) (err error) {
	bytes, err := ioutil.ReadAll(input)
	if err != nil {
		return err
	}
	p := &dotParse{
		output:   output,
		vertices: make(map[graphVertex]int),
	}
	return dot.StreamParse(bytes, p)
}