File: int_digraph.go

package info (click to toggle)
golang-github-cheekybits-genny 1.0.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 336 kB
  • sloc: makefile: 17; sh: 3
file content (30 lines) | stat: -rw-r--r-- 535 bytes parent folder | download
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
// This file was automatically generated by genny.
// Any changes will be lost if this file is regenerated.
// see https://github.com/cheekybits/genny

package bugreports

type DigraphInt struct {
	nodes map[int][]int
}

func NewDigraphInt() *DigraphInt {
	return &DigraphInt{
		nodes: make(map[int][]int),
	}
}

func (dig *DigraphInt) Add(n int) {
	if _, exists := dig.nodes[n]; exists {
		return
	}

	dig.nodes[n] = nil
}

func (dig *DigraphInt) Connect(a, b int) {
	dig.Add(a)
	dig.Add(b)

	dig.nodes[a] = append(dig.nodes[a], b)
}