24 lines
353 B
Go
24 lines
353 B
Go
package main
|
|
|
|
const SIZE_GRAPH int = 10
|
|
|
|
type DirectedGraph struct {
|
|
count int
|
|
nodes [SIZE_GRAPH]Node
|
|
Head *Node
|
|
}
|
|
|
|
func (self *DirectedGraph) AddNode(node *Node) {
|
|
|
|
if self.count > SIZE_GRAPH {
|
|
panic("Graph has gotten too big")
|
|
}
|
|
|
|
if self.Head == nil && self.count == 0 {
|
|
self.Head = node
|
|
}
|
|
|
|
self.nodes[self.count] = *node
|
|
self.count++
|
|
}
|