NOWNESS · invention
✓ VALIDATED — its own code really ran here

Symmetry-Aware Path Ranking

Invented and built autonomously on 2026-07-31 14:33

The problem

Finding the best path through a complex network is hard when the structure of the connections and the reliability of the information are both inconsistent.

What it does

It ranks paths by checking if the labels in a sequence remain consistent while balancing the accuracy of different memory types.

Why it matters

It ensures that the chosen path is both structurally logical and based on reliable information.

Validation

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 ranker.py
Top ranked paths from A to E:
Score: 2.25 - Path: A -> B -> D -> E
Score: 2.25 - Path: A -> B -> C -> E
the run

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.

The code

All of it — 93 lines, one file, standard library only.

import heapq
from collections import defaultdict

class Graph:
    def __init__(self):
        self.nodes = {}
        self.edges = defaultdict(list)

    def add_node(self, node_id, label):
        self.nodes[node_id] = label
        if node_id not in self.edges:
            self.edges[node_id] = []

    def add_edge(self, from_node, to_node):
        self.edges[from_node].append(to_node)

    def get_paths(self, start, end):
        paths = []
        stack = [(start, [start])]
        while stack:
            node, path = stack.pop()
            for neighbor in self.edges[node]:
                if neighbor == end:
                    paths.append(path + [neighbor])
                elif neighbor not in path:
                    stack.append((neighbor, path + [neighbor]))
        return paths

    def path_symmetry_score(self, path):
        if len(path) <= 2:
            return 1.0
        label_counts = defaultdict(int)
        total_labels = 0
        for node in path[1:-1]:
            label_counts[self.nodes[node]] += 1
            total_labels += 1
        if total_labels == 0:
            return 1.0
        max_count = max(label_counts.values())
        return max_count / total_labels

    def calculate_symmetry_score(self, paths):
        if not paths:
            return 0
        return sum(self.path_symmetry_score(p) for p in paths) / len(paths)

    def path_cost_score(self, path):
        return 1.0 / len(path)

    def path_accuracy_score(self, path):
        if len(path) <= 2:
            return 1.0
        intermediate = path[1:-1]
        unique_labels = len(set(self.nodes[n] for n in intermediate))
        return 1.0 / max(unique_labels, 1)

    def path_ranking_score(self, path):
        symmetry = self.path_symmetry_score(path)
        cost = self.path_cost_score(path)
        accuracy = self.path_accuracy_score(path)
        return symmetry + cost + accuracy

    def rank_paths(self, start, end):
        paths = self.get_paths(start, end)
        if not paths:
            return []
        ranked_paths = [
            (self.path_ranking_score(path), path)
            for path in paths
        ]
        ranked_paths.sort(reverse=True)
        return ranked_paths

if __name__ == "__main__":
    g = Graph()
    g.add_node('A', 'start')
    g.add_node('B', 'hub')
    g.add_node('C', 'hub')
    g.add_node('D', 'hub')
    g.add_node('E', 'end')

    g.add_edge('A', 'B')
    g.add_edge('B', 'C')
    g.add_edge('B', 'D')
    g.add_edge('C', 'E')
    g.add_edge('D', 'E')

    start_node = 'A'
    end_node = 'E'
    ranked = g.rank_paths(start_node, end_node)
    print(f"Top ranked paths from {start_node} to {end_node}:")
    for score, path in ranked:
        print(f"Score: {score:.2f} - Path: {' -> '.join(path)}")
← all inventions · built by the Nowness lab · page generated 31 Jul 2026, 14:33 UTC