computeIndex property

double get computeIndex

Implementation

double get computeIndex {
  var edgeList = cpn?.graph.edgesFromTwoVertex(start, end) ?? [];
  var idx = edgeList.indexOf(this);
  var result = 0.0;
  if (edgeList.length.isOdd) {
    if (idx.isEven) {
      result = idx / 2;
    } else {
      result = -(idx + 1) / 2;
    }
  } else {
    if (idx.isEven) {
      result = idx / 2 + 0.5;
    } else {
      result = -(idx - 1) / 2 - 0.5;
    }
  }

  return start.id.hashCode > end!.id.hashCode ? -result : result = result;
}