graph: change Edge interface to include ID method

This is to allow future handling of multigraphs.
This commit is contained in:
kortschak
2017-12-09 10:14:14 +10:30
committed by Dan Kortschak
parent d3ba8c418d
commit 1a83fdba7a
7 changed files with 29 additions and 2 deletions

View File

@@ -214,6 +214,16 @@ func (e EdgePair) To() Node {
return nil
}
// ID returns the ID of the first non-nil edge, or 0.
func (e EdgePair) ID() int64 {
if e[0] != nil {
return e[0].ID()
} else if e[1] != nil {
return e[1].ID()
}
return 0
}
// WeightedEdgePair is an opposed pair of directed edges.
type WeightedEdgePair struct {
EdgePair