mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 23:52:47 +08:00
graph: change Edge interface to include ID method
This is to allow future handling of multigraphs.
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user