1,954 questions
-2
votes
0
answers
75
views
How'd you make algorithm that'll find shortest way to sort sequence of numbers just by applying function f(x) that will make x to closest lower prime? [closed]
Imagine you get sequence of integers:
[a1 a2 a3 ... an]
where:
1 <= a <= 10^6
1 <= n <= 10^6
You are given a function f(x) that can change a number to the closest lower prime number, or ...
-3
votes
1
answer
122
views
PriorityQueue Comparator weird behavior when sort order is fetched from hashmap
While working in LeetCode 675, I came across a weird behavior with PriorityQueue Comparator that I can't explain.
For brevity, I'll state the gist of the problem statement; interested parties can read ...
5
votes
1
answer
80
views
Can bi-directional breadth-first search be used to enumerate ALL shortest paths between two specific nodes in an unweighted directed (acyclic?) graph?
It is alleged that the standard BFS can be extended to output all possible shortest paths between two given vertices in a directed unweighted graph (without loops? it does not seem to matter whether ...
5
votes
2
answers
152
views
Algorithm to Minimize Time to Complete All Endings in a Multi-Branch Game with Limited Save Points
In a multi-branch game, there are 𝑛 possible endings. You can think of it as a directed tree with 𝑛 leaf nodes, where each edge has a weight of 1. Instead of playing through the entire game to reach ...
-1
votes
1
answer
104
views
Error in Java : incompatible types: cannot infer type arguments for PriorityQueue<>
class Solution {
class City{
int city;
long time;
City(int c, long t){
city = c;
time = t;
}
}
public int countPaths(int n, int[][] ...
1
vote
2
answers
179
views
Error: recursive reference to query "shortestflight" must not appear within a subquery
From "Montreal" as the origin point, I'm trying to find the shortest path to go to another city. But I'm having difficulty when a city is looped.
demo at db<>fiddle
create table ...
0
votes
1
answer
53
views
Efficiently converting edgelist to distance matrix in Python
R user learning Python here. I have an undirected unweighted edgelist and I want a distance matrix, showing the shortest path between all my nodes. There are about 30000 nodes and 40000 edges, and my ...
0
votes
1
answer
117
views
How to find shortest path in neo4j with property filters but without GDS?
I want to find a shortest path in neo4j between a start and end node. The graph is weighted with properties "costs" and "transit_time".
I wanna find the shortest path in terms of ...
2
votes
1
answer
103
views
Struggling with Shortest Path Calculation in Graph with Special Edge Weights
I've been working on a problem where I need to find the shortest path in a graph considering two types of edge weights: normal and special. Check Problem Here.
I have constructed an adjacency list and ...
1
vote
1
answer
165
views
Single Source - Single Destination Shortest Path (DFS + DP) - Time complexity?
Context:
I want to write an algorithm for finding the shortest(least cost) path from a fixed source to a fixed destination node in a weighted directed graph with non negative weights (can have cycles)....
0
votes
1
answer
137
views
how to find a path from source to target with necessary points constraint by A star algorithm
Using A star algorithm, it is easy to calculate the shortest path from the source point to target point. What if we add the constraint of necessary points? How to solve it ?
necessary points is a set ...
0
votes
1
answer
307
views
Bellman-Ford with Adjacency List (Shortest-path with negative weights)
I'm implementing my own version of the Bellman-Ford algorithm to find shortest paths with negative weights. However I'm not sure if this is correct, since in my opinion the complexity in my solution ...
4
votes
1
answer
307
views
Python (GIS): How to convert geometric lines (in the form of a LineString) to a Complete Graph network using Networkx
TL;DR How to convert a geodataframe of LineStrings to a Complete Graph with NetworkX?
I have a geodataframe of a collection of linestrings that geographically represent a road network (purple). I have ...
0
votes
3
answers
171
views
How to reconstruct the shortest path with BFS (Javascript) for Knight chess piece?
I'm currently working for a project with TOP and I'm asked to find the shortest path between 2 squares with a Knight on a 8x8 chessboard. Imagine I want to go from 0,0 to 7,7, my algo need to return ...
0
votes
0
answers
43
views
Algorithm for finding a subset of nodes in a weighted connected graph such that the distance between any pair nodes are under a postive number?
I was given a problem that in a connected, weighted graph G = (N, A), find a connected subgraph G_s = (N_s, A_s), where |N_s| <= l and A_s = {(i, j): i \in N_s, j \in N_s, (i, j) \in A}, such that ...
1
vote
0
answers
55
views
Scalable Python Shortest Path on Large DAG with Multiple Walkers
I have a large (~10 million edges and some ~100k nodes) Directed Acyclic Graph (DAG) and a list of walkers (around ~30k), and each of these walker has an origin and destination node which get ...
1
vote
1
answer
152
views
undirected graph - Shortest path with Vertex and edges Weight
the exercise:
in undirected graph vertices have can have weights in addition to the weights of edges
This problem is to write algorithem that finding the cheapest path between vertices a and b in a ...
0
votes
1
answer
101
views
Simplification of O((V + E) logV) time complexity
the time complexity of dijkstra algorithm is O((V + E) logV)
if my graph is E < V like the image I attached below
can I drop the E and simplify it to O(VlogV)?
If can, I would like to know why the ...
0
votes
1
answer
85
views
Condition for loop in Floyd–Warshall algorithm
I'm learning a basic shortest-route algorithm specifically Floyd–Warshall algorithm.
I understood how efficient it is when finding 'All to All' distance.
But while reading a code from the book I'm ...
0
votes
0
answers
39
views
Shortest path finding for multiple points in 2d ware house
2d ware house layout
in 2d layout task is to find shortest distance for getting material from storage points
Z00 ,Z01 .... may be start or end points based on user input
A1A1 B1A1 ....are storage ...
0
votes
1
answer
123
views
Shortest path of weighted and directed graph in Neo4j
I created a map of city in Neo4j using OpenStreetMap and OpenAddresses data. I want to find the shortest path from one address to another. The problem is that, when I'm using function apoc.algo....
0
votes
0
answers
110
views
Finding paths and shortest paths in a map
I am working on this program that reads a file of metro stations and converts it into a graph. Then it does the following tasks:
• It identifies all the stations belonging on the same line of a given ...
0
votes
1
answer
337
views
Find multiple (all) shortest paths between a pair of vertices using Boost's Dijkstra shortest path implementation
I have been using Boost to find the shortest paths (SP) between two nodes in a graph using their implementation of Dijkstra's shortest path algorithm dijkstra_shortest_paths. This function returns a ...
0
votes
0
answers
40
views
Cant store find the shortest path in the dijkstra algorithm
I have implemented a dijkstra algorithm that calculates the shortest distance for every node from the start node, but I am not able to retrieve the shortest path for these nodes. I watched a youtube ...
1
vote
1
answer
128
views
Get weighted shortest path in an Openlink Virtuoso Knowledge Graph
Context
Given a certain KG with the following structure
<distanceTo:1> <weight> 3 .
<distanceTo:1> <weight> 4 .
<a> ...