orderedEntryConcepts property

List<Concept> orderedEntryConcepts

Implementation

List<Concept> get orderedEntryConcepts {
  var orderedEntryConceptsCount = 0;
  var orderedEntryConcepts = <Concept>[];
  for (var c = 0; c < 9; c++) {
    var sameExternalCountConcepts = <Concept>[];
    for (var concept in entryConcepts) {
      if (concept.parents.externalCount == c) {
        sameExternalCountConcepts.add(concept);
      }
    }
    // order by external child count (from high to low)
    var orderedSameExternalCountConcepts = <Concept>[];
    for (var s = 8; s >= 0; s--) {
      for (var concept in sameExternalCountConcepts) {
        if (concept.children.externalCount == s) {
          orderedSameExternalCountConcepts.add(concept);
        }
      }
    }
    assert(sameExternalCountConcepts.length ==
        orderedSameExternalCountConcepts.length);
    for (var concept in orderedSameExternalCountConcepts) {
      orderedEntryConcepts.add(concept);
      orderedEntryConceptsCount++;
    }
    if (orderedEntryConceptsCount == entryConcepts.length) {
      return orderedEntryConcepts;
    }
  }
  var msg = """
    Not all entry concepts are ordered by external parent count (from low to high).
    There is an entry concept in your model that has more than 9 external neighbors.
    Inform the EDNetCore authors to increase this restriction.
  """;
  throw ConceptException(msg);
}