385 questions
Advice
0
votes
2
replies
31
views
DFS VS DSFVisit
I'm in college learning about DFS and BFS. I knew about this before, although what's throwing me in a loop is DFSVisit.
I just want to know what's the difference between DFS and DFSVisit. Is DFS just ...
3
votes
3
answers
110
views
Iterative graph traversal: non-BFS and non-DFS ordering
Consider this traversal algorithm in pseudocode:
Traverse(G, v):
S is stack
stack.push(v)
label v as visited
while S is not empty:
v = S.pop()
for all w in G....
3
votes
1
answer
155
views
Efficient Algorithems to find position of vector in 2D array
I have an interesting problem but cannot find the relevant literature, so need algorithem suggestions or just the correct way to phrase the problem so I can find the literature.
I'm given a vector of ...
2
votes
1
answer
107
views
For given edge, find all nodes the edge lies on any path from
I have undirected connected graph with one main node (denoted by M in examples below).
I am trying to find efficient algorithm to following specification:
input is set of edges (denoted by thick ...
0
votes
0
answers
56
views
Indirect and direct link in a tree
Suppose 3 sets of nodes, each corresponding to a distinct set in an undirected graph:
Set-A = {1, 2, 3, 4, 5}
Set-B = {6, 7, 8, 9, 10}
Set-C = {11, 12, 13, 14, 15}
The graph is defined by ...
0
votes
0
answers
37
views
Neo4j traversal framework - how to effectively test some node is not reached
I have a Neo4j 5.26 database with graph (minimized example):
CREATE (x1:L {id:1})-[:R]->(x2:L {id:2})-[:R]->(x3:L {id:3})
-[:R]->(x4:L {id:4})-[:R]->(x5:L {id:5})
and some ...
2
votes
1
answer
138
views
Graph traversal algorithm using shapely geometry points
I am trying to create a path planning algorithm for a robotic mower to cut all the grass in a defined area while avoiding obstacles or restricted areas. I am using the Python Shapely library to define ...
5
votes
5
answers
315
views
Finding loops between numbers in a list of sets
I marked my answer as the answer because it is the one that is doing what I was wanting and anyone wanting to do the same thing should start there. But I would love to see a better answer (order of ...
2
votes
1
answer
250
views
Why are back edges and forward edges said to be impossible in BFS for an undirected graph?
Is it true that there are no back edges and no forward edges in a BFS of an undirected graph?
I feel this is incorrect. Here is my counterexample (graph is represent using adjacency list):
0 : 1
...
0
votes
1
answer
47
views
Dynamic WITH statement
Is it possible to dynamically construct a WITH statement?
I have to do a graph traversal, but I don't know in advance which collections contain the graph nodes. I have tried to create the statement ...
0
votes
1
answer
71
views
gremlin apache: how to use the weights of edges to define the order in which an edge is followed?
I'm trying to traverse a graph (directed) where the edges have weights.
How do I use the weights to define the order in which an edge is followed: the lower the weight (module of the weight to be ...
0
votes
1
answer
154
views
Postgres slow recursive CTE graph traversal due to visited edges
I have a postgres table with a 100K± records representing edges of graph (will grows even to 1M) defined as (I left the relevant parts only):
CREATE TABLE public.collection_lineages (
id int8 NOT ...
-1
votes
1
answer
50
views
Which algorithm can I use to number the graph as follows
Each node in the above graph has been numbered.
I am trying to find the graph traversal algorithm that can be used to number the graph in this order. Appreciate if anyone can suggest an algorithm that ...
0
votes
1
answer
42
views
Find shortest path from multiple source vertex and output the each path length sum against the target vertices
I have written the below AQL shortest path traversal query to find the shortest paths from a set of start vertices to a set of target vertices.
In the output I would like a consolidated result. ...
0
votes
0
answers
130
views
Given an undirected weighted graph, how to find the minimum cost so that I can start from any node and traverse all other nodes that is in the graph?
Title: Finding the Maximum of Minimum Costs in a Modified Kruskal's Algorithm
Question:
I'm working on a graph problem where I need to find the maximum of the minimum costs starting from a specific ...
1
vote
0
answers
36
views
Approximation Algorithms for the Longest Simple Path in a Directed Graph
I am implementing a new approximation algorithm for finding the longest simple path in a directed, unweighted graph from a starting node s to a destination node t. I would like to compare my algorithm'...
1
vote
1
answer
73
views
leetCode590. N-ary Tree Postorder Traversal
I am trying to solve LeetCode problem 590. N-ary Tree Postorder:
Given the root of an n-ary tree, return the postorder traversal of its nodes' values.
I made code considering each condition.
I ...
1
vote
1
answer
153
views
ArangoDB Graph Traversal: Excluding a Node Based on Property While Inferring Indirect Connections
I'm working with ArangoDB and have a graph traversal scenario where I need to skip a specific node based on a property, but still infer an indirect connection (edge) between two other nodes. My graph ...
0
votes
1
answer
88
views
Python IDDFS missing potential results
I'm using bfs and iddfs to find the optimal solution of the 8 tile puzzle, however, my IDDFS is missing solutions and i'm not sure why. ive checked and it seems that every node visits all it's sons, ...
0
votes
1
answer
43
views
Path finding in grid
I trying to print all the paths in a mxm matrix which terminate if I visit an already visited node. I have tried a recursive solution but i am not sure how to handle the base case
def is_valid_move(x, ...
0
votes
0
answers
82
views
How to detect any cycles in lisp list
I am thinking about the problem of detecting cycles in lisp lists (based on cons cells). Traditional cycle detection algorithms like Floyd's (Tortoise and hare) or Brent's algorithm all assume that ...
0
votes
1
answer
88
views
Traverse directed graph without "catching up"
I have a (acyclical) directed graph, which I want to traverse in the right order.
The arrows indicate dependencies - a node should only be visited if all previous nodes are already visited.
I tried ...
0
votes
1
answer
20
views
Retrieving distinct data without using the DISTINCT keyword for better query performance
I have a very large graph. My objective is the following:
Return pathways related to the target 'GIPR' and also related to compounds. Where the compounds are related to the disease 'Leukemia'
My ...
1
vote
0
answers
32
views
Can you give me adjacency list of a graph whose BFS and topological sort are not equivalent?
Can you give me adjacency list of a graph whose BFS and topological sort are not equivalent ? I visualze them the same way but googling if they both are same never quite provided a satisfactory ...
1
vote
0
answers
210
views
ArcadeDB | `All hosts are considered unavailable due to previous exceptions. Check the error log to find the actual reason.`
What are the details of your problem?
Why is Tinkerpop-Gremlin AnonymousTraversalSource finding ArcadeDB unavailable?
I looked at log/arcadedb.log.x files but they're empty.
And the Log4j2 logs also ...
0
votes
2
answers
261
views
Is There A Better Way To Delete Vertexes In JanusGraph?
Is there a way to just drop() all of the Vertexes in JanusGraph like OrientDB?
g.V().drop().iterate() takes about 2 minutes to traverse through 70005 basic vertices.
JanusGraph's JanusGraph (interface)...
1
vote
1
answer
158
views
Why is it slow when OpenMP runs in parallel independent instances of shortest path algorithm that uses BFS (BFS in itself is not parallelized)?
I am trying to run multiple instances of a shortest path algorithm, for independent pairs of nodes in a graph.
The algorithm internally uses the bfs method, which is "sandboxed" (self-...
0
votes
1
answer
504
views
Connect to External JanusGraph Server With JanusGraphFactory
Problem
How do you connect to an external JanusGraph Server with JanusGraphFactory?
I don't know what I'm doing and new to JanusGraph and Graph-Databases in-general.
What is the JanusGraph > ...
0
votes
2
answers
436
views
Caching BFS traversal in an undirected and unweighted graph
I have an undirected and unweighted graph with about a million nodes - visualized in a matrix format.
Representation of a sample graph:
The red cells are blocked.
My problem is to find the shortest ...
0
votes
1
answer
183
views
Is there a way to calculate an optimal route between multiple nodes with different types of travel
In the game EVE Online there is a map with systems, these systems can be traversed by gates or jump drives but there are some limitations:
If the system is in range (jump drives have a max range ...
3
votes
1
answer
216
views
Code to find the shortest path in Breadth First Search
#Breadth First Search
graph = {
'S' : ['A','B'],
'A' : ['B','C','D'],
'B' : ['C'],
'C' : ['D'],
'D' : []
}
visited = []
queue = []
goal = 'D'
def bfs(visited, graph, node):
...
0
votes
1
answer
206
views
Using Project + valueMap in combination with where
I have the following graph: https://gremlify.com/vxkibjtoz3b
if u can't open the link the graph is lloking the following:
You can see there 2 queries. The first one:
g.V().out("r").as("...
1
vote
0
answers
389
views
How to count the number of subgraphs in a collection?
I have been able to find the number of subgraphs in a collection using the below query, after much trial and error and documentation consultation. It seems to work ok. It's crafted to work in the ...
-2
votes
1
answer
91
views
Is that a valid BFS? [closed]
I recently wrote a function to traverse a graph, along those lines:
def traverse(batch: list[str], seen: set[str]):
if not batch:
return
new_batch = []
for node in batch:
...
0
votes
0
answers
93
views
Do we always have to run Bellman-Ford N-1 times?
This is more a theoretical question because I can see this question being asked in an exam.
Assuming we have a directed graph G(V,E) with |V| = 10 and we want to know the shortest path from S to all ...
0
votes
1
answer
86
views
Same output shortest paths regardless of distances in Networkx module
I create a digraph of 14 nodes using the Networkx module. I am getting the same output paths irrespective of changing distances when using the in-built functions.
Assume the weights are as follows for ...
0
votes
1
answer
485
views
Recursive DFS graph traversal in Scala
I've seen the following code to traverse a graph depth first, in Scala:
def dfs(node: Node, seen: Set[Node]) = {
visit(node)
node.neighbours.filterNot(seen).foreach(neighbour => dfs(node, ...
1
vote
1
answer
403
views
Stuck on Python "KeyError: <exception str() failed>" in BFS code of a water jug scenario
Intended Function of code: Takes a user input for the volume of 3 jars(1-9) and output the volumes with one of the jars containing the target length. jars can be Emptied/Filled a jar, or poured from ...
1
vote
1
answer
219
views
Acyclic undirected graph allocation problem
We have an allocation problem: each node is a fuel source, and every edge contains a number of evenly spaced out lamps (think of them as being 1 m apart from each other). Each fuel source can power ...
-1
votes
2
answers
105
views
Calculate the lowest cost of running several resource collectors on an undirected acyclic graph
We have an undirected acyclic graph where there is only a single path between two connected nodes that may look something like this.
Simple guide to the image:
Black numbers: Node id's (note that ...
0
votes
0
answers
44
views
How can I avoid collecting multiple instances of vertices and edges?
I've created a query to return all "descendant" edges and vertices for a particular queried vertex.
The query works, but it duplicates edges and vertices with each iteration of the repeat ...
2
votes
1
answer
555
views
Embedded gremlin server via gremlin-go library in golang
I'm new to Golang and need to find an analog to org.apache.tinkerpop.gremlin.tinkergraph.structure. TinkerGraph to use gremlin methods for traversing embedded graphs without connection to graph ...
0
votes
1
answer
435
views
how to take tree roots in a DFS forest?
A DFS starting at some vertex v explores the graph by building up a
tree that contains all vertices that are reachable from v and all
edges that are used to reach these vertices. We call this tree a ...
0
votes
2
answers
554
views
Find longest path through an undirected edge-weighted tree
I'm looking for an algorithm to find the longest path through an edge weighted tree. The graph is acyclic and connected, but not directed and only sparsely connected, doesn't have a defined start ...
-1
votes
2
answers
406
views
Algorithm to traverse edges of a hex grid between two points
Background
Looking to trace a path between two points on a hexagonal grid while following the nearest edge.
Problem
Determining the algorithm to constrain the all iterations after the first one to the ...
4
votes
1
answer
87
views
Translating from Cypher query to traversal framework for neo4j
I have this traversal:
TraversalDescription td = graph.traversalDescription()
.depthFirst()
.relationships(RelationshipTypes.CHILD, Direction.INCOMING)
....
1
vote
1
answer
367
views
Determine whether certain nodes on a graph are directly connected
How can I determine whether selected nodes on a graph are directly connected?
I think, I need to calculate paths for each selected node to all of the other selected nodes. Then, when I have the path, ...
0
votes
1
answer
290
views
BFS in time O(m) for a directed graph
In an undirected graph the running time of BFS is O(m+n). Is it possible to get a running time of O(m) in a directed graph? (|V|=n, |E|=m)
0
votes
1
answer
483
views
Neo4j Cypher - How to query for multiple variables within a single traversal
I have a case of scenario that there are TOURIST who wants to travel and every country has VISA control and there is a path along countries so some of connections you are not allowed to visit that ...
1
vote
1
answer
53
views
Pointer error in Directed Graph in Python
I'm trying to implement a Directed graph in python by creating a class Vertex. A vertex has the name and the adjacent as a list containing another instance of class Vertex . below is the code.
The ...