Finding the best route through a complex network is hard because it is difficult to balance staying on a stable path with finding one that leads to the best outcome.
It looks at different paths in a network and ranks them by measuring both how stable the path is and how much it is expected to grow.
It allows for choosing routes that are both reliable and productive at the same time.
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_scorer.py Top ranked paths by Taylor-Expansion Score: Path: ['A', 'C', 'D'], Score: 7.00 Path: ['A', 'B', 'D'], Score: 4.00
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 — 64 lines, one file, standard library only.
# Taylor-Expansion Path Scorer
import math
from itertools import combinations
def covariance(x, y):
n = len(x)
mean_x = sum(x)/n
mean_y = sum(y)/n
return sum((x[i]-mean_x)*(y[i]-mean_y) for i in range(n)) / n
def taylor_predict(points, t):
# Linear prediction using first two points
t0, r0 = points[0]
t1, r1 = points[1]
slope = (r1 - r0)/(t1 - t0)
return r0 + slope*(t - t0)
def graph_paths(graph, start, end, max_len=3):
# Simple BFS path generator
from collections import deque
queue = deque([(start, [start])])
paths = []
while queue:
node, path = queue.popleft()
if node == end and len(path) <= max_len:
paths.append(path)
continue
for neighbor in graph.get(node, []):
if neighbor not in path:
queue.append((neighbor, path + [neighbor]))
return paths
def score_path(path, graph, reward_func):
# Structural stability score (covariance of node degrees)
degrees = [len(graph.get(node, {})) for node in path]
cov_score = covariance(degrees[:-1], degrees[1:]) if len(degrees) > 1 else 0
# Predictive score (Taylor expansion of reward function)
rewards = [reward_func(node) for node in path]
pred_score = taylor_predict(list(enumerate(rewards)), len(path))
return cov_score + pred_score
def main():
# Example graph structure
graph = {
'A': ['B', 'C'],
'B': ['A', 'D'],
'C': ['A', 'D'],
'D': ['B', 'C']
}
# Example reward function (simulated)
def reward(node):
return {'A': 1, 'B': 2, 'C': 3, 'D': 4}.get(node, 0)
paths = graph_paths(graph, 'A', 'D')
ranked = sorted(zip(paths, map(lambda p: score_path(p, graph, reward), paths)),
key=lambda x: x[1], reverse=True)
print("Top ranked paths by Taylor-Expansion Score:")
for path, score in ranked:
print(f"Path: {path}, Score: {score:.2f}")
if __name__ == "__main__":
main()