It is difficult to see which connections in a complex web of information are the most significant or influential. Identifying the most important paths manually becomes overwhelming as the network grows.
It looks at a web of information and ranks different paths based on how deeply connected they are. It provides a list of paths sorted by their overall importance score.
It allows you to quickly identify the most influential connections within a complex network.
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 graph_path_ranker_v2.py Top ranked paths: Path: A -> C -> D -> F | Score: 15 Path: A -> C -> E -> F | Score: 15 Path: A -> B -> D -> F | Score: 12 Path: A -> C -> D | Score: 10 Path: A -> C -> E | Score: 10
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 — 48 lines, one file, standard library only.
# graph_path_ranker_v2.py
import collections
def compute_in_degrees(graph):
in_degrees = collections.defaultdict(int)
for node, neighbors in graph.items():
for neighbor in neighbors:
in_degrees[neighbor] += 1
return in_degrees
def generate_paths(graph, start, max_depth):
paths = []
queue = collections.deque([(start, [start])])
while queue:
node, path = queue.popleft()
for neighbor in graph.get(node, []):
new_path = path + [neighbor]
paths.append(new_path)
if len(new_path) - 1 < max_depth:
queue.append((neighbor, new_path))
return paths
def calculate_score(path, graph, in_degrees):
hops = len(path) - 1
degree_sum = sum(len(graph.get(node, [])) for node in path)
centrality_sum = sum(in_degrees.get(node, 0) for node in path)
return hops * degree_sum * centrality_sum
def main():
graph = {
'A': ['B', 'C'],
'B': ['D'],
'C': ['D', 'E'],
'D': ['F'],
'E': ['F'],
'F': []
}
start_node = 'A'
max_depth = 3
in_degrees = compute_in_degrees(graph)
paths = generate_paths(graph, start_node, max_depth)
scored_paths = [(path, calculate_score(path, graph, in_degrees)) for path in paths]
scored_paths.sort(key=lambda x: x[1], reverse=True)
print('Top ranked paths:')
for path, score in scored_paths[:5]:
print(f'Path: {" -> ".join(path)} | Score: {score}')
if __name__ == "__main__":
main()