Documentation
¶
Index ¶
- Constants
- Variables
- func DfsDo(st Searcher, op string, g *MultiGraph, srcIds []int, targetIds []int, topK int) (pathsb []byte, err error)
- func EdgesCsvToJson(csvFp string, jsonFp string) error
- func FromJsonFile[T EdgeConstraint](fn string) (seq []T, e error)
- func GenerateRandomEntitiesJson(base string, count int, removeOld bool, c RandomEntitySeqInfo)
- func GenerateRandomLimitOrdersCsv(base string, tpl string, count int, removeOld bool, c RandomEdgeSeqInfo)
- func IdsHash(id1, id2 int) (uint64, error)
- func IsChainViewsEquals(resPaths [][]ChainView, wantPaths [][]ChainView, mistakesAllowed int) bool
- func LoadText(fn string) ([]byte, error)
- func PathsToChainView(pathsb []byte) ([][]ChainView, error)
- func PathsToJson(paths []PriorityQueue) ([]byte, error)
- func PriorityQueues2BinaryFile(fp string, pqs []PriorityQueue) error
- func ToCsvFile(fn string, seq []*SingleEdge) error
- func ToJsonFile[T EdgeConstraint](fn string, seq []T) error
- func Weight(a *Entity) float64
- func WriteText(fn string, data []byte) error
- type BellmanFord
- func (st *BellmanFord) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
- func (st *BellmanFord) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- func (st *BellmanFord) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- type ChainView
- type Dfs
- type DfsColored
- func (st *DfsColored) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
- func (st *DfsColored) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- func (st *DfsColored) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- type DfsMemo
- func (st *DfsMemo) AddLimitOrders(edges EdgeSeq) (MEdgeSeq, error)
- func (st *DfsMemo) Arbitrage(srcIds []int, topK int) (res []PriorityQueue)
- func (st *DfsMemo) Init()
- func (st *DfsMemo) RemoveLimitOrders(medges MEdgeSeq)
- func (st *DfsMemo) SetDeepLimit(v int)
- func (st *DfsMemo) SetFnMode(mode int)
- func (st *DfsMemo) SetGraph(g *MultiGraph)
- func (st *DfsMemo) SetTreshold(t float64)
- func (st *DfsMemo) SetTresholdMode(mode int)
- func (st *DfsMemo) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
- func (st *DfsMemo) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- func (st *DfsMemo) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- type DfsStacked
- func (st *DfsStacked) BestCycles() (res []EdgeSeq)
- func (st *DfsStacked) SetDeepLimit(v int)
- func (st *DfsStacked) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
- func (st *DfsStacked) TopKCycles(topK int) (res []PriorityQueue)
- func (st *DfsStacked) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- func (st *DfsStacked) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- type EdgeConstraint
- type EdgeSeq
- type Entity
- type EntityRaw
- type EntitySeq
- type FloydWarshall
- func (st *FloydWarshall) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
- func (st *FloydWarshall) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- func (st *FloydWarshall) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
- type Item
- type LimitOrderService
- type MEdgeSeq
- type MultiEdge
- func (e *MultiEdge) Add(s *SingleEdge) error
- func (e *MultiEdge) AddMany(s EdgeSeq) error
- func (e *MultiEdge) AddManyWithoutUniqueChecking(s EdgeSeq)
- func (e *MultiEdge) BuildIndex()
- func (e *MultiEdge) Len() int
- func (e *MultiEdge) MergeWithoutUniqueChecking(m *MultiEdge)
- func (e *MultiEdge) Remove(entityId string) error
- func (e *MultiEdge) RemoveMany(m *MultiEdge) bool
- func (e *MultiEdge) RemoveManyByIds(entityIds []string) error
- func (e *MultiEdge) Update()
- func (e *MultiEdge) UpdateRelation(entityId string, relation float64) error
- type MultiGraph
- func (g *MultiGraph) Add(edges EdgeSeq, status int) (MEdgeSeq, error)
- func (g *MultiGraph) Build(ent EdgeSeq)
- func (g *MultiGraph) GetEdgeIndex(id1, id2 int) (int, bool)
- func (g *MultiGraph) Pred(v int) MEdgeSeq
- func (g *MultiGraph) Remove(medges MEdgeSeq, status int)
- func (g *MultiGraph) Succ(u int) MEdgeSeq
- func (g *MultiGraph) UpdateRelation(ent EdgeSeq) error
- type PriorityQueue
- func BinaryFile2PriorityQueues(fp string) ([]PriorityQueue, error)
- func NewPriorityQueue(size int, capacity int) PriorityQueue
- func PriorityQueue2SortedArray(pq PriorityQueue, asc bool) (sa PriorityQueue)
- func ProcessOutsideEdges(pq PriorityQueue, deepLimit int, topK int, reverseEdgeSeq bool, ...) (res PriorityQueue)
- func (pq *PriorityQueue) Append(value interface{}, priority float64)
- func (pq *PriorityQueue) Init()
- func (pq PriorityQueue) Len() int
- func (pq PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) PopItem() (item *Item)
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) PushItem(item *Item)
- func (pq PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) Update(item *Item, value interface{}, priority float64)
- type RandomEdgeSeqInfo
- type RandomEntitySeqInfo
- type Searcher
- type SingleEdge
- type TreeItem
- type TreeItemStat
- type TreeNode
Constants ¶
View Source
const ( THR_NOT_USED = iota THR_CUSTOM THR_ZERO )
View Source
const ( LO_NOT_IN_CHAIN = iota LO_PARENT LO_CHILD LO_CURRENT )
View Source
const ( FN_ALL_PATHS = iota FN_LO_ONLY )
View Source
const ( UNDEFINED = iota LIMIT_ORDER )
Variables ¶
View Source
var MAX_WEIGHT float64 = math.Inf(1)
View Source
var MIN_WEIGHT float64 = math.Inf(-1)
Functions ¶
func EdgesCsvToJson ¶
func FromJsonFile ¶
func FromJsonFile[T EdgeConstraint](fn string) (seq []T, e error)
func GenerateRandomEntitiesJson ¶
func GenerateRandomEntitiesJson(base string, count int, removeOld bool, c RandomEntitySeqInfo)
func GenerateRandomLimitOrdersCsv ¶
func GenerateRandomLimitOrdersCsv(base string, tpl string, count int, removeOld bool, c RandomEdgeSeqInfo)
func IsChainViewsEquals ¶
func PathsToChainView ¶
func PathsToJson ¶
func PathsToJson(paths []PriorityQueue) ([]byte, error)
func PriorityQueues2BinaryFile ¶
func PriorityQueues2BinaryFile(fp string, pqs []PriorityQueue) error
func ToCsvFile ¶
func ToCsvFile(fn string, seq []*SingleEdge) error
func ToJsonFile ¶
func ToJsonFile[T EdgeConstraint](fn string, seq []T) error
Types ¶
type BellmanFord ¶
type BellmanFord struct {
// contains filtered or unexported fields
}
func (*BellmanFord) TopK ¶
func (st *BellmanFord) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
func (*BellmanFord) TopKOneToMany ¶
func (st *BellmanFord) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
func (*BellmanFord) TopKOneToOne ¶
func (st *BellmanFord) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
type ChainView ¶
type ChainView struct {
In int64 `json:"in"`
Out int64 `json:"out"`
Chain string `json:"chain"`
Value float64 `json:"value"`
}
func EdgeSeqToChainView ¶
type Dfs ¶
type Dfs struct {
// contains filtered or unexported fields
}
func (*Dfs) SetDeepLimit ¶
func (*Dfs) SetMultiGraph ¶
func (st *Dfs) SetMultiGraph(g *MultiGraph)
func (*Dfs) SetTopKValue ¶
type DfsColored ¶
type DfsColored struct {
Dfs
// contains filtered or unexported fields
}
func (*DfsColored) TopK ¶
func (st *DfsColored) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
func (*DfsColored) TopKOneToMany ¶
func (st *DfsColored) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
func (*DfsColored) TopKOneToOne ¶
func (st *DfsColored) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
type DfsMemo ¶
type DfsMemo struct {
Dfs
// contains filtered or unexported fields
}
func (*DfsMemo) Arbitrage ¶
func (st *DfsMemo) Arbitrage(srcIds []int, topK int) (res []PriorityQueue)
func (*DfsMemo) RemoveLimitOrders ¶
func (*DfsMemo) SetDeepLimit ¶
func (*DfsMemo) SetGraph ¶
func (st *DfsMemo) SetGraph(g *MultiGraph)
func (*DfsMemo) SetTreshold ¶
func (*DfsMemo) SetTresholdMode ¶
func (*DfsMemo) TopK ¶
func (st *DfsMemo) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
func (*DfsMemo) TopKOneToMany ¶
func (st *DfsMemo) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
func (*DfsMemo) TopKOneToOne ¶
func (st *DfsMemo) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
type DfsStacked ¶
type DfsStacked struct {
// contains filtered or unexported fields
}
func (*DfsStacked) BestCycles ¶
func (st *DfsStacked) BestCycles() (res []EdgeSeq)
func (*DfsStacked) SetDeepLimit ¶
func (st *DfsStacked) SetDeepLimit(v int)
func (*DfsStacked) TopK ¶
func (st *DfsStacked) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
func (*DfsStacked) TopKCycles ¶
func (st *DfsStacked) TopKCycles(topK int) (res []PriorityQueue)
func (*DfsStacked) TopKOneToMany ¶
func (st *DfsStacked) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
func (*DfsStacked) TopKOneToOne ¶
func (st *DfsStacked) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
type EdgeConstraint ¶
type EdgeConstraint interface {
*Entity | *SingleEdge
}
type EdgeSeq ¶
type EdgeSeq []*SingleEdge
func (*EdgeSeq) BuildVertexIndex ¶
func (EdgeSeq) GetRelation ¶
func (EdgeSeq) MarshalJSON ¶
func (EdgeSeq) ReverseEdgeSeq ¶
func (seq EdgeSeq) ReverseEdgeSeq()
func (*EdgeSeq) SetVertexIndex ¶
type Entity ¶
type Entity struct {
EntityId string `json:"EntityId"`
Id1 int `json:"Id1"`
Id2 int `json:"Id2"`
Relation float64 `json:"Relation"`
Id1i int `json:"Id1i"`
Id2i int `json:"Id2i"`
}
func (*Entity) MarshalJSON ¶
func (*Entity) UnmarshalJSON ¶
type EntitySeq ¶
type EntitySeq []*Entity
func GenerateRandomEntities ¶
func GenerateRandomEntities(c RandomEntitySeqInfo) EntitySeq
type FloydWarshall ¶
type FloydWarshall struct{}
func (*FloydWarshall) TopK ¶
func (st *FloydWarshall) TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
func (*FloydWarshall) TopKOneToMany ¶
func (st *FloydWarshall) TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
func (*FloydWarshall) TopKOneToOne ¶
func (st *FloydWarshall) TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
type Item ¶
func (Item) MarshalJSON ¶
type LimitOrderService ¶
type LimitOrderService struct {
// contains filtered or unexported fields
}
TODO
func (*LimitOrderService) AddWrapped ¶
func (s *LimitOrderService) AddWrapped(lo *SingleEdge)
func (*LimitOrderService) AddWrappedList ¶
func (s *LimitOrderService) AddWrappedList(los EdgeSeq)
func (*LimitOrderService) Remove ¶
func (s *LimitOrderService) Remove(id string)
type MEdgeSeq ¶
type MEdgeSeq []*MultiEdge
func SingleToMultiEdges ¶
func (MEdgeSeq) ReverseEdgeSeq ¶
func (seq MEdgeSeq) ReverseEdgeSeq()
type MultiEdge ¶
type MultiEdge struct {
SingleEdge
// contains filtered or unexported fields
}
func (*MultiEdge) Add ¶
func (e *MultiEdge) Add(s *SingleEdge) error
func (*MultiEdge) AddManyWithoutUniqueChecking ¶
func (*MultiEdge) BuildIndex ¶
func (e *MultiEdge) BuildIndex()
func (*MultiEdge) MergeWithoutUniqueChecking ¶
func (*MultiEdge) RemoveMany ¶
func (*MultiEdge) RemoveManyByIds ¶
type MultiGraph ¶
type MultiGraph struct {
Edges MEdgeSeq
EdgeIndex map[uint64]int
VertexIndex map[int]int
// contains filtered or unexported fields
}
func (*MultiGraph) Build ¶
func (g *MultiGraph) Build(ent EdgeSeq)
func (*MultiGraph) GetEdgeIndex ¶
func (g *MultiGraph) GetEdgeIndex(id1, id2 int) (int, bool)
func (*MultiGraph) Pred ¶
func (g *MultiGraph) Pred(v int) MEdgeSeq
func (*MultiGraph) Remove ¶
func (g *MultiGraph) Remove(medges MEdgeSeq, status int)
func (*MultiGraph) Succ ¶
func (g *MultiGraph) Succ(u int) MEdgeSeq
func (*MultiGraph) UpdateRelation ¶
func (g *MultiGraph) UpdateRelation(ent EdgeSeq) error
type PriorityQueue ¶
type PriorityQueue []*Item
func BinaryFile2PriorityQueues ¶
func BinaryFile2PriorityQueues(fp string) ([]PriorityQueue, error)
func NewPriorityQueue ¶
func NewPriorityQueue(size int, capacity int) PriorityQueue
func PriorityQueue2SortedArray ¶
func PriorityQueue2SortedArray(pq PriorityQueue, asc bool) (sa PriorityQueue)
func ProcessOutsideEdges ¶
func ProcessOutsideEdges(pq PriorityQueue, deepLimit int, topK int, reverseEdgeSeq bool, onlyLimitOrders bool) (res PriorityQueue)
func (*PriorityQueue) Append ¶
func (pq *PriorityQueue) Append(value interface{}, priority float64)
func (*PriorityQueue) Init ¶
func (pq *PriorityQueue) Init()
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) PopItem ¶
func (pq *PriorityQueue) PopItem() (item *Item)
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (*PriorityQueue) PushItem ¶
func (pq *PriorityQueue) PushItem(item *Item)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
func (*PriorityQueue) Update ¶
func (pq *PriorityQueue) Update(item *Item, value interface{}, priority float64)
type RandomEdgeSeqInfo ¶
type RandomEntitySeqInfo ¶
type Searcher ¶
type Searcher interface {
TopK(g *MultiGraph, srcId int, targetId int, topK int) (res PriorityQueue)
TopKOneToOne(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
TopKOneToMany(g *MultiGraph, srcIds []int, targetIds []int, topK int) (res []PriorityQueue)
}
type SingleEdge ¶
func FromCsvFile ¶
func FromCsvFile(fn string) (seq []*SingleEdge, e error)
func GenerateRandomLimitOrders ¶
func GenerateRandomLimitOrders(fp string, count int, percDiff float64) []*SingleEdge
func (*SingleEdge) MarshalJSON ¶
func (b *SingleEdge) MarshalJSON() ([]byte, error)
func (*SingleEdge) UnmarshalJSON ¶
func (b *SingleEdge) UnmarshalJSON(data []byte) error
func (*SingleEdge) Update ¶
func (e *SingleEdge) Update()
func (*SingleEdge) UpdateRelation ¶
func (e *SingleEdge) UpdateRelation(relation float64)
type TreeItemStat ¶
type TreeItemStat struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.

