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

@@ -4,15 +4,18 @@
package graph
// Node is a graph node. It returns a graph-unique integer ID.
// Node is a graph node. It returns a graph-unique integer node ID.
type Node interface {
ID() int64
}
// Edge is a graph edge. In directed graphs, the direction of the
// edge is given from -> to, otherwise the edge is semantically
// unordered.
// unordered. An Edge returns an ID which must be graph-unique
// integer edge ID if the containing graph is a multigraph, otherwise
// no constraint exists on ID values.
type Edge interface {
ID() int64
From() Node
To() Node
}