It is difficult to measure exactly how much two different routes or paths deviate from each other when they share some points but move in different directions.
It takes two paths and calculates a mathematical score that shows how different they are based on the unique steps taken.
It provides a clear way to quantify the difference between multiple routes or paths.
It was run inside an isolated container with no network access. This is the exact command and the real output it produced — captured process output, not written by a model.
$ python3 path_step_jaccard_divergence.py usage: path_step_jaccard_divergence.py [-h] --path1 PATH1 --path2 PATH2 path_step_jaccard_divergence.py: error: the following arguments are required: --path1, --path2
A screenshot of that run.
A clean run proves this does what is shown above, in a CPU-only sandbox. It is a small research demo — not a production tool, and nothing here was published anywhere.
All of it — 18 lines, one file, standard library only.
import argparse
def jaccard_distance(set1, set2):
intersection = set1 & set2
union = set1 | set2
return 1 - len(intersection) / len(union) # 1 - Jaccard Index
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Path-Step Jaccard Divergence calculator.')
parser.add_argument('--path1', type=str, required=True, help='First path as comma-separated nodes')
parser.add_argument('--path2', type=str, required=True, help='Second path as comma-separated nodes')
args = parser.parse_args()
set1 = set(args.path1.split(','))
set2 = set(args.path2.split(','))
distance = jaccard_distance(set1, set2)
print(f'Path-Step Jaccard Divergence: {distance:.4f}')