September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,51 @@
# independent/0 emits an array of the dependencies that have no dependencies
# Input: an object representing a normalized dependency graph
def independent:
. as $G
| reduce keys[] as $key
([];
. + ((reduce $G[$key][] as $node
([];
if ($G[$node] == null or ($G[$node]|length)==0) then . + [$node]
else .
end ))))
| unique;
# normalize/0 eliminates self-dependencies in the input dependency graph.
# Input: an object representing a dependency graph.
def normalize:
. as $G
| reduce keys[] as $key
($G;
.[$key] as $nodes
| if $nodes and ($nodes|index($key)) then .[$key] = $nodes - [$key] else . end);
# minus/1 removes all the items in ary from each of the values in the input object
# Input: an object representing a dependency graph
def minus(ary):
. as $G | reduce keys[] as $key ($G; $G[$key] -= ary);
# tsort/0 emits the topologically sorted nodes of the input,
# in ">" order.
# Input is assumed to be an object representing a dependency
# graph and need not be normalized.
def tsort:
# _sort: input: [L, Graph], where L is the tsort so far
def _tsort:
def done: [.[]] | all( length==0 );
.[0] as $L | .[1] as $G
| if ($G|done) then $L + (($G|keys) - $L)
else
($G|independent) as $I
| if (($I|length) == 0)
then error("the dependency graph is cyclic: \($G)")
else [ ($L + $I), ($G|minus($I))] | _tsort
end
end;
normalize | [[], .] | _tsort ;
tsort

View file

@ -0,0 +1,14 @@
{"des_system_lib": [ "std", "synopsys", "std_cell_lib", "des_system_lib", "dw02", "dw01", "ramlib", "ieee"],
"dw01": [ "ieee", "dw01", "dware", "gtech"],
"dw02": [ "ieee", "dw02", "dware"],
"dw03": [ "std", "synopsys", "dware", "dw03", "dw02", "dw01", "ieee", "gtech"],
"dw04": [ "dw04", "ieee", "dw01", "dware", "gtech"],
"dw05": [ "dw05", "ieee", "dware"],
"dw06": [ "dw06", "ieee", "dware"],
"dw07": [ "ieee", "dware"],
"dware": [ "ieee", "dware"],
"gtech": [ "ieee", "gtech"],
"ramlib": [ "std", "ieee"],
"std_cell_lib": [ "ieee", "std_cell_lib"],
"synopsys": []
}

View file

@ -0,0 +1,2 @@
$ jq -c -f tsort.jq tsort.json
["ieee","std","synopsys","dware","gtech","ramlib","std_cell_lib","dw01","dw02","des_system_lib","dw03","dw04","dw05","dw06","dw07"]