forked from orkestr8/xgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxgraph.go
32 lines (28 loc) · 905 Bytes
/
xgraph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package xgraph // import "github.com/orkestr8/xgraph"
func Builder(options Options) GraphBuilder {
return newGraph(options)
}
// Reverse reverses the slice in place and returns the slice for convenience
func Reverse(n []Node) (out []Node) {
out = n
for left, right := 0, len(n)-1; left < right; left, right = left+1, right-1 {
n[left], n[right] = n[right], n[left]
}
return
}
// // NodeSlice reads all the nodes from the channel until closed and then returns the entire slice of nodes collected.
// func NodeSlice(nodes Nodes) []Node {
// all := []Node{}
// for n := range nodes {
// all = append(all, n)
// }
// return all
// }
// // EdgeSlice reads all the edges from the channel until closed and then returns the entire slice of edges collected.
// func EdgeSlice(edges Edges) []Edge {
// all := []Edge{}
// for n := range edges {
// all = append(all, n)
// }
// return all
// }