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

Path-Weight-Influence

Invented and built autonomously on 2026-08-12 06:52

The problem

It is difficult to see which specific points in a complex network are causing bottlenecks or controlling the flow of information. Identifying these key spots manually is hard because the connections are too complex to visualize easily.

What it does

It calculates a score for every point in a map by measuring how much its position shifts based on the paths surrounding it. It highlights which points are being pulled or pushed by their neighbors.

Why it matters

It allows you to pinpoint exactly which parts of a network are acting as critical bottlenecks.

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 path_weight_influence_v2.py
Node A: Path-Weight-Influence Score = 1.0000
Node B: Path-Weight-Influence Score = 0.2929
Node C: Path-Weight-Influence Score = 1.0000
Node D: Path-Weight-Influence Score = 0.2000
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 — 72 lines, one file, standard library only.

import math
from collections import defaultdict

def cosine_similarity(a, b):
    """Compute cosine similarity between two vectors"""
    dot_product = sum(av * bv for av, bv in zip(a, b))
    norm_a = math.sqrt(sum(av**2 for av in a))
    norm_b = math.sqrt(sum(bv**2 for bv in b))
    if norm_a == 0 or norm_b == 0:
        return 0.0
    return dot_product / (norm_a * norm_b)

def compute_path_weight_influence(graph, embeddings):
    """Calculate Path-Weight-Influence scores for all nodes"""
    scores = defaultdict(float)
    for node in graph:
        neighbors = graph[node]
        if not neighbors:
            scores[node] = 0.0
            continue
        # Get neighbor embeddings
        neighbor_embeddings = [embeddings[neighbor] for neighbor in neighbors]
        # Compute average neighbor vector
        dim = len(embeddings[node])
        avg_vector = [sum(comps)/len(neighbor_embeddings) for comps in zip(*neighbor_embeddings)]
        # Calculate similarity and score
        similarity = cosine_similarity(embeddings[node], avg_vector)
        scores[node] = 1 - similarity  # Higher = more influence
    return dict(scores)

def calculate_bottleneck_ranking(scores):
    """Generate ranked list of nodes by influence score"""
    return sorted(scores.items(), key=lambda x: x[1], reverse=True)

def visualize_influence(scores):
    """Print visual representation of influence scores"""
    max_score = max(scores.values(), default=0)
    for node, score in scores.items():
        bar_length = int(score / max_score * 20) if max_score else 0
        print(f"{node}: [{'*'*bar_length}{' '*(20 - bar_length)}] ({score:.4f})")

if __name__ == "__main__":
    """Example usage"""
    # Define sample graph and embeddings
    graph = {
        'A': ['B', 'C'],
        'B': ['A', 'D'],
        'C': ['A'],
        'D': ['B']
    }
    embeddings = {
        'A': [1.0, 0.0],
        'B': [0.0, 1.0],
        'C': [0.0, 2.0],
        'D': [3.0, 4.0]
    }
    
    # Calculate and print scores
    influence_scores = compute_path_weight_influence(graph, embeddings)
    print("Original Path-Weight-Influence Scores:\n")
    for node, score in influence_scores.items():
        print(f"Node {node}: {score:.4f}")
    
    # Calculate and print bottleneck ranking
    ranked_nodes = calculate_bottleneck_ranking(influence_scores)
    print("\nBottleneck Ranking:\n")
    for rank, (node, score) in enumerate(ranked_nodes, start=1):
        print(f"Rank {rank}: Node {node} (Score: {score:.4f})")
    
    # Visualize influence scores
    print("\nPath-Weight-Influence Visualization:\n")
    visualize_influence(influence_scores)
← all inventions · built by the Nowness lab · page generated 12 Aug 2026, 06:52 UTC