cmake-basis / modules Goto Github PK
View Code? Open in Web Editor NEWCMake modules of the CMake BASIS project.
Home Page: https://cmake-basis.github.io
License: Other
CMake modules of the CMake BASIS project.
Home Page: https://cmake-basis.github.io
License: Other
# https://github.com/cmake-basis/modules/blob/master/TopologicalSort.cmake
include(TopologicalSort.cmake)
set(target_names a b c)
# c -> b -> a -> c
set(target_dependencies_a b)
set(target_dependencies_b c)
set(target_dependencies_c a)
message("before toposort: target_names = ${target_names}")
topological_sort(target_names target_dependencies_ "")
message("after toposort: target_names = ${target_names}")
output
before toposort: target_names = a;b;c
after toposort: target_names = c;b;a
ideally, the cycle error should also print the cycle
in python im using
import networkx
debug = True
scope_installs = ["a", "b", "c"]
# c -> b -> a -> c
target_depends_map = {
"a": ["b"],
"b": ["c"],
"c": ["a"],
}
# build dependency graph
depgraph = networkx.DiGraph()
depgraph_roots = set()
for target_name in scope_installs:
target_depends = target_depends_map.get(target_name, [])
for dep in target_depends:
depgraph.add_edge(dep, target_name)
# find roots of graph
depgraph_roots = []
for component in networkx.weakly_connected_components(depgraph):
subgraph = depgraph.subgraph(component)
depgraph_roots.extend([n for n,d in subgraph.in_degree() if d==0])
# check for cycles
# toposort throws exception, but does not print cycles
depgraph_cycles = list(networkx.simple_cycles(depgraph))
if depgraph_cycles:
raise Exception(f"found cycles in depgraph: {depgraph_cycles}")
targets_sorted = list(networkx.topological_sort(depgraph))
debug and print(f"targets_sorted = {' '.join(targets_sorted)}")
output
Exception: found cycles in depgraph: [['a', 'c', 'b']]
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.