fako1024 / topo Goto Github PK
View Code? Open in Web Editor NEWDependency resolution based on topological sort of a directed graph (for arbitrary types)
License: Other
Dependency resolution based on topological sort of a directed graph (for arbitrary types)
License: Other
This package is nearly perfect for my use case. The only thing I'm missing is know how many stages I'll need to process data while running as parallel as possible. I'll use your readme example to illustrate:
// List of all simple strings (to be sorted)
var stringsToSort = []string{
"A", "B", "C", "D", "E", "F", "G", "H",
}
// List of dependencies
var stringDependencies = []topo.Dependency{
topo.Dependency{Child: "B", Parent: "A"},
topo.Dependency{Child: "B", Parent: "C"},
topo.Dependency{Child: "B", Parent: "D"},
topo.Dependency{Child: "A", Parent: "E"},
topo.Dependency{Child: "D", Parent: "C"},
}
Sorted list of strings: [E A C D B F G H]
If each of those letters represented a function, I'd have to wait for each stage of dependencies to complete before running the next.
Sorted list of strings in parallel stages:
[
[F G H E C],
[A D],
[B],
]
In that list, F
, G
, H
, E
and C
aren't dependent on anything, so they can run first and all in parallel. Next, A
and D
need E
and C
to finish respectively, but have no cross-dependencies, so they can run in parallel. That just leaves B
, which has to run in its own stage after A
, C
and D
complete.
How difficult do you think it would be to add that functionality?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.