It is difficult to see which specific points in a complex network act as critical bottlenecks or single points of failure. Identifying these constraints is hard because they are often hidden within large amounts of interconnected data.
The tool analyzes a network and assigns a score to each point based on how much it restricts high-value connections. It highlights which specific spots are the most critical constraints.
It allows you to pinpoint exactly which parts of a system are most vulnerable or essential to its flow.
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_bottleneck.py Path-Weighting Bottleneck Scores: A: 19 D: 19 E: 19 C: 12 B: 7
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 — 85 lines, one file, standard library only.
#!/usr/bin/env python3
import sys
def find_all_paths(graph, sources, sinks):
paths = []
def dfs(current, path, visited):
visited.add(current)
path.append(current)
if current in sinks:
paths.append(path.copy())
else:
if current in graph:
for neighbor, _ in graph[current]:
if neighbor not in visited:
dfs(neighbor, path, visited)
path.pop()
visited.remove(current)
for source in sources:
dfs(source, [], set())
return paths
def calculate_path_weight(path, graph):
total = 0
for i in range(len(path) - 1):
current = path[i]
next_node = path[i+1]
for neighbor, weight in graph.get(current, []):
if neighbor == next_node:
total += weight
break
return total
def calculate_bottleneck_scores(paths, graph):
scores = {}
for path in paths:
path_weight = calculate_path_weight(path, graph)
for node in path:
if node not in scores:
scores[node] = 0
scores[node] += path_weight
return scores
def main():
# Example graph definition
edges = {
'A': [('B', 2), ('C', 3)],
'B': [('D', 1)],
'C': [('D', 5)],
'D': [('E', 4)],
}
# Find all nodes (including those not in edges as keys but referenced as neighbors)
all_nodes = set(edges.keys())
for node in edges:
for neighbor, _ in edges[node]:
all_nodes.add(neighbor)
# Calculate incoming edges to find sources
incoming = {node: 0 for node in all_nodes}
for node in edges:
for neighbor, _ in edges[node]:
incoming[neighbor] += 1
sources = [node for node in all_nodes if incoming[node] == 0]
sinks = [node for node in all_nodes if (node not in edges or not edges[node])]
# Find all paths from sources to sinks
paths = find_all_paths(edges, sources, sinks)
# Calculate bottleneck scores
scores = calculate_bottleneck_scores(paths, edges)
# Sort scores in descending order
sorted_scores = sorted(scores.items(), key=lambda x: -x[1])
# Print results
print("Path-Weighting Bottleneck Scores:")
for node, score in sorted_scores:
print(f"{node}: {score}")
if __name__ == "__main__":
main()