Finding Public Favorites Based on Asymmetric Distance Relationships

Intimacy between people can be quantified by an inverse relationship with perceived distance. Importantly, this distance perception is asymmetric and directional. For instance, person A might perceive a distance of 1 to person B, while B perceives a distance of 100000 to A. Additionally, distance relationships are transitive: if person A consid ...

Posted on Sat, 27 Jun 2026 17:09:24 +0000 by mbarmawi

Graph Theory: Multi-source and Single-source Shortest Path Algorithms

Shortest path problems in graph theory often rely on the concept of relaxation. Relaxation occurs when a path from node u to v can be shoretned by routing through an intermediate node k, i.e., if dist[u][v] > dist[u][k] + dist[k][v], we update dist[u][v] accordingly. Floyd-Warshall Algorithm (All-Pairs Shortest Paths) To compute shortest pat ...

Posted on Wed, 03 Jun 2026 18:20:34 +0000 by little_tris

Dijkstra Algorithm Implementation Guide

Dijkstra Algortihm: O(n²) Approach Dijkstra's algorithm solves the single-source shortest path problem for graphs with non-negative edge weights. It efficiently computes the minimum distance from a starting vertex to all other vertices using a greedy approach. Algorithm Overview Initialization: Set the source distance to 0 and all other vertic ...

Posted on Tue, 26 May 2026 18:58:39 +0000 by benyamin

Minimum Button Presses for a Strange Elevator

A building has an unusual elevator system. Each floor i (where 1 ≤ i ≤ N) has a fixed value K[i], which determines how many floors the elevator moves when the "up" or "down" button is pressed. The elveator can only move up by K[i] floors or down by K[i] floors from floor i. If the target floor would be below 1 or above N, th ...

Posted on Mon, 18 May 2026 01:53:57 +0000 by bobdabuilder

Identifying Edges on Shortest Paths in Directed Graphs

To determine which edges can lie on a shortest path from source S to target T in a directed graph, compute shortest distances from S to all nodes. Then, perform a reverse BFS starting from T on the transposed graph. For each dequeued node cur and its neighbor nex in the transposed graph, if Dist[nex] == Dist[cur] - weight(cur->nex) holds, th ...

Posted on Sat, 16 May 2026 15:21:00 +0000 by dustinnoe