Documentation ¶
Index ¶
- type DAG
- func (d *DAG) AddEdge(start, end Vertice, weight int) error
- func (d *DAG) Clone() *DAG
- func (d *DAG) CloseDAG(start, end Vertice) *DAG
- func (d *DAG) EndingVertices() Vertices
- func (d *DAG) Equal(a *DAG) bool
- func (d *DAG) FromVertices(v Vertice) Vertices
- func (d *DAG) GetVertice(ty, id string) Vertice
- func (d *DAG) Iterate(start Vertice, init []interface{}, fn IterateFn) []interface{}
- func (d *DAG) JSON() *JSON
- func (d *DAG) Len() int
- func (d *DAG) Longest(start, end Vertice, withWeight bool) Vertices
- func (d *DAG) Merge(a *DAG) error
- func (d *DAG) ReachDAG(start Vertice) *DAG
- func (d *DAG) ReduceDAG(start, end Vertice) *DAG
- func (d *DAG) RemoveEdge(start, end Vertice)
- func (d *DAG) Reverse() *DAG
- func (d *DAG) Shortest(start, end Vertice, withWeight bool) Vertices
- func (d *DAG) StartingVertices() Vertices
- func (d *DAG) ToVertices(v Vertice) Vertices
- func (d *DAG) Vertices(ty string) Vertices
- type IterateFn
- type JSON
- type Vertice
- type Vertices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DAG ¶
type DAG struct {
// contains filtered or unexported fields
}
DAG is a directed acyclic graph.
func FromJSON ¶ added in v0.3.0
FromJSON returns a DAG from JSON structured data, return nil if some data invalid.
func (*DAG) AddEdge ¶
AddEdge adds a connecting pairs of vertices into the DAG. the vertices should not be nil, not be equal, and not form a cyclic graph. the method can be called multiple times.
func (*DAG) CloseDAG ¶
CloseDAG returns a new transitive closure DAG with the most edges that represents the same reachability relation.
func (*DAG) EndingVertices ¶
EndingVertices returns ending vertices in the DAG that don't connected to any other vertices.
func (*DAG) FromVertices ¶
FromVertices returns vertices in the DAG that connected to the vertice v.
func (*DAG) GetVertice ¶
GetVertice returns a vertice with type and id in the DAG, returns nil if not found.
func (*DAG) Merge ¶ added in v0.3.0
Merge merge two DAG into one, return error if cyclic graph will come into being
func (*DAG) ReachDAG ¶
ReachDAG returns a new sub DAG with the most edges that starting vertice may reach to.
func (*DAG) ReduceDAG ¶
ReduceDAG returns a new transitive reduction DAG with the fewest edges that represents the same reachability relation.
func (*DAG) RemoveEdge ¶
RemoveEdge remove the direct connecting in the vertices pair.
func (*DAG) StartingVertices ¶
StartingVertices returns starting vertices in the DAG that have no other vertices connected to them.
func (*DAG) ToVertices ¶
ToVertices returns vertices in the DAG that the vertice v connected to them.
type JSON ¶ added in v0.3.0
type JSON struct { Vertices []Vertice `json:"vertices"` Edges map[string]map[string]int `json:"edges"` }
JSON ...