It is difficult to determine if a sequence of events is consistent when both the structure of the connections and the timing of the data change.
It analyzes paths in a network and assigns a score based on how well the shape of the connections matches the timeline of the data.
It provides a way to verify both the structure and the chronological flow of information simultaneously.
It was run in the sandbox and it failed. run output shows an error/traceback — the artifact does NOT run clean.
$ python3 scorer.py
File "/work/scorer.py", line 25
while current != end:
IndentationError: unexpected indentNo screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.
All of it — 66 lines, one file, standard library only.
# Temporal-Symmetry Graph Scorer
import itertools
from datetime import datetime
class GraphNode:
def __init__(self, label, timestamp):
self.label = label
self.timestamp = datetime.fromisoformat(timestamp)
self.connections = {}
def add_connection(self, node, weight=1.0):
self.connections[node] = weight
class TemporalSymmetryScorer:
def __init__(self, nodes):
self.nodes = {node.label: node for node in nodes}
def graph_path_symmetry_score(self):
all_paths = []
for start, end in itertools.combinations(self.nodes.values(), 2):
if end in start.connections:
path = [start]
current = start
n
while current != end:
current = next(node for node in current.connections if end in current.connections)
path.append(current)
all_paths.append(path)
if not all_paths:
return 0.0
label_counts = {}
for path in all_paths:
labels = [node.label for node in path]
label_counts['-'.join(labels)] = label_counts.get('-'.join(labels), 0) + 1
unique_labels = len(label_counts)
max_count = max(label_counts.values())
return max_count / unique_labels if unique_labels else 1.0
def temporal_decay_score(self):
timestamps = [node.timestamp.timestamp() for node in self.nodes.values()]
avg_time = sum(timestamps) / len(timestamps)
time_diffs = [(t - avg_time) ** 2 for t in timestamps]
return 1 / (sum(time_diffs) + 1e-9)
def combined_score(self):
symmetry = self.graph_path_symmetry_score()
temporal = self.temporal_decay_score()
return 0.7 * symmetry + 0.3 * temporal
if __name__ == "__main__":
# Initialize sample graph
node_a = GraphNode('A', '2024-01-01T00:00:00')
node_b = GraphNode('A', '2024-01-02T00:00:00')
node_c = GraphNode('B', '2024-01-03T00:00:00')
node_a.add_connection(node_b)
node_b.add_connection(node_c)
node_a.add_connection(node_c)
scorer = TemporalSymmetryScorer([node_a, node_b, node_c])
print(f"Symmetry Score: {scorer.graph_path_symmetry_score():.2f}")
print(f"Temporal Score: {scorer.temporal_decay_score():.2f}")
print(f"Combined Score: {scorer.combined_score():.2f}")